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