Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qeglfshooks.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
6#include <QLoggingCategory>
7
9
10#ifdef EGLFS_PLATFORM_HOOKS
11
12QEglFSDeviceIntegration *qt_egl_device_integration()
13{
14 extern QEglFSHooks *platformHooks;
15 return platformHooks;
16}
17
18#else
19
20namespace {
22{
23public:
25 ~DeviceIntegration() { delete m_integration; }
26 QEglFSDeviceIntegration *integration() { return m_integration; }
27private:
28 QEglFSDeviceIntegration *m_integration;
29};
30}
31
32Q_GLOBAL_STATIC(DeviceIntegration, deviceIntegration)
33
34DeviceIntegration::DeviceIntegration()
35 : m_integration(nullptr)
36{
37 QStringList pluginKeys = QEglFSDeviceIntegrationFactory::keys();
38 if (!pluginKeys.isEmpty()) {
39 // Some built-in logic: Prioritize either X11 or KMS/DRM.
40 if (qEnvironmentVariableIsSet("DISPLAY")) {
41 const QString x11key = QStringLiteral("eglfs_x11");
42 if (pluginKeys.contains(x11key)) {
43 pluginKeys.removeOne(x11key);
44 pluginKeys.prepend(x11key);
45 }
46 } else {
47 const QString kmskey = QStringLiteral("eglfs_kms");
48 if (pluginKeys.contains(kmskey)) {
49 pluginKeys.removeOne(kmskey);
50 pluginKeys.prepend(kmskey);
51 }
52 }
53
54 // The environment variable can override everything.
55 QString requested = qEnvironmentVariable("QT_QPA_EGLFS_INTEGRATION");
56 if (requested.isNull()) {
57 // Device-specific makespecs may define a preferred plugin.
58#ifdef EGLFS_PREFERRED_PLUGIN
59#define DEFAULT_PLUGIN EGLFS_PREFERRED_PLUGIN
60#define STR(s) #s
61#define STRQ(s) STR(s)
62 requested = QStringLiteral(STRQ(DEFAULT_PLUGIN));
63#endif
64 }
65
66 // Treat "none" as special. There has to be a way to indicate
67 // that plugins must be ignored when the device is known to be
68 // functional with the default, non-specialized integration.
69 if (requested != QStringLiteral("none")) {
70 if (!requested.isEmpty()) {
71 pluginKeys.removeOne(requested);
72 pluginKeys.prepend(requested);
73 }
74 qCDebug(qLcEglDevDebug) << "EGL device integration plugin keys (sorted):" << pluginKeys;
75 while (!m_integration && !pluginKeys.isEmpty()) {
76 QString key = pluginKeys.takeFirst();
77 qCDebug(qLcEglDevDebug) << "Trying to load device EGL integration" << key;
78 m_integration = QEglFSDeviceIntegrationFactory::create(key);
79 }
80 }
81 }
82
83 if (!m_integration) {
84 // Use a default, non-specialized device integration when no plugin is available.
85 // For some systems this is sufficient.
86 qCDebug(qLcEglDevDebug) << "Using base device integration";
87 m_integration = new QEglFSDeviceIntegration;
88 }
89}
90
92{
93 return deviceIntegration()->integration();
94}
95
96#endif // EGLFS_PLATFORM_HOOKS
97
98QT_END_NAMESPACE
QEglFSDeviceIntegration * integration()
Combined button and popup list for selecting options.
QEglFSDeviceIntegration * qt_egl_device_integration()