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
qlinuxfbintegration.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
7#if QT_CONFIG(kms)
8#include "qlinuxfbdrmscreen.h"
9#endif
10
11#include <QtGui/private/qgenericunixfontdatabase_p.h>
12#include <QtGui/private/qgenericunixeventdispatcher_p.h>
13#include <qpa/qplatformservices.h>
14
15#include <QtFbSupport/private/qfbvthandler_p.h>
16#include <QtFbSupport/private/qfbbackingstore_p.h>
17#include <QtFbSupport/private/qfbwindow_p.h>
18#include <QtFbSupport/private/qfbcursor_p.h>
19
20#include <QtGui/private/qguiapplication_p.h>
21#include <qpa/qplatforminputcontextfactory_p.h>
22#include <qpa/qwindowsysteminterface.h>
23
24#if QT_CONFIG(libinput)
25#include <QtInputSupport/private/qlibinputhandler_p.h>
26#endif
27
28#if QT_CONFIG(evdev)
29#include <QtInputSupport/private/qevdevmousemanager_p.h>
30#include <QtInputSupport/private/qevdevkeyboardmanager_p.h>
31#include <QtInputSupport/private/qevdevtouchmanager_p.h>
32#endif
33
34#if QT_CONFIG(tslib)
35#include <QtInputSupport/private/qtslib_p.h>
36#endif
37
39
40using namespace Qt::StringLiterals;
41
42QLinuxFbIntegration::QLinuxFbIntegration(const QStringList &paramList)
43 : m_primaryScreen(nullptr),
44 m_fontDb(new QGenericUnixFontDatabase)
45{
46#if QT_CONFIG(kms)
47 if (qEnvironmentVariableIntValue("QT_QPA_FB_DRM") != 0)
48 m_primaryScreen = new QLinuxFbDrmScreen(paramList);
49#endif
50 if (!m_primaryScreen)
51 m_primaryScreen = new QLinuxFbScreen(paramList);
52}
53
54QLinuxFbIntegration::~QLinuxFbIntegration()
55{
56 QWindowSystemInterface::handleScreenRemoved(m_primaryScreen);
57}
58
59void QLinuxFbIntegration::initialize()
60{
61 if (m_primaryScreen->initialize())
62 QWindowSystemInterface::handleScreenAdded(m_primaryScreen);
63 else
64 qWarning("linuxfb: Failed to initialize screen");
65
66 m_inputContext = QPlatformInputContextFactory::create();
67
68 m_vtHandler.reset(new QFbVtHandler);
69
70 if (!qEnvironmentVariableIntValue("QT_QPA_FB_DISABLE_INPUT"))
71 createInputHandlers();
72}
73
74bool QLinuxFbIntegration::hasCapability(QPlatformIntegration::Capability cap) const
75{
76 switch (cap) {
77 case ThreadedPixmaps: return true;
78 case WindowManagement: return false;
79 case RhiBasedRendering: return false;
80 default: return QPlatformIntegration::hasCapability(cap);
81 }
82}
83
84QPlatformBackingStore *QLinuxFbIntegration::createPlatformBackingStore(QWindow *window) const
85{
86 return new QFbBackingStore(window);
87}
88
89QPlatformWindow *QLinuxFbIntegration::createPlatformWindow(QWindow *window) const
90{
91 return new QFbWindow(window);
92}
93
94QAbstractEventDispatcher *QLinuxFbIntegration::createEventDispatcher() const
95{
96 return createUnixEventDispatcher();
97}
98
99QList<QPlatformScreen *> QLinuxFbIntegration::screens() const
100{
101 QList<QPlatformScreen *> list;
102 list.append(m_primaryScreen);
103 return list;
104}
105
106QPlatformFontDatabase *QLinuxFbIntegration::fontDatabase() const
107{
108 return m_fontDb.data();
109}
110
111QPlatformServices *QLinuxFbIntegration::services() const
112{
113 if (m_services.isNull())
114 m_services.reset(new QPlatformServices);
115
116 return m_services.data();
117}
118
119void QLinuxFbIntegration::createInputHandlers()
120{
121#if QT_CONFIG(libinput)
122 if (!qEnvironmentVariableIntValue("QT_QPA_FB_NO_LIBINPUT")) {
123 new QLibInputHandler("libinput"_L1, QString());
124 return;
125 }
126#endif
127
128#if QT_CONFIG(tslib)
129 bool useTslib = qEnvironmentVariableIntValue("QT_QPA_FB_TSLIB");
130 if (useTslib)
131 new QTsLibMouseHandler("TsLib"_L1, QString());
132#endif
133
134#if QT_CONFIG(evdev)
135 m_kbdMgr = new QEvdevKeyboardManager("EvdevKeyboard"_L1, QString(), this);
136 new QEvdevMouseManager("EvdevMouse"_L1, QString(), this);
137#if QT_CONFIG(tslib)
138 if (!useTslib)
139#endif
140 new QEvdevTouchManager("EvdevTouch"_L1, QString() /* spec */, this);
141#endif
142}
143
144QPlatformNativeInterface *QLinuxFbIntegration::nativeInterface() const
145{
146 return const_cast<QLinuxFbIntegration *>(this);
147}
148
149QFunctionPointer QLinuxFbIntegration::platformFunction(const QByteArray &function) const
150{
151 Q_UNUSED(function);
152 return nullptr;
153}
154
155#if QT_CONFIG(evdev)
156void QLinuxFbIntegration::loadKeymap(const QString &filename)
157{
158 if (m_kbdMgr)
159 m_kbdMgr->loadKeymap(filename);
160 else
161 qWarning("QLinuxFbIntegration: Cannot load keymap, no keyboard handler found");
162}
163
164void QLinuxFbIntegration::switchLang()
165{
166 if (m_kbdMgr)
167 m_kbdMgr->switchLang();
168 else
169 qWarning("QLinuxFbIntegration: Cannot switch language, no keyboard handler found");
170}
171#endif
172
173QT_END_NAMESPACE
QLinuxFbIntegration(const QStringList &paramList)
Combined button and popup list for selecting options.