1// Copyright (C) 2019 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
4#ifndef QPLATFORMINTEGRATION_WAYLAND_H
5#define QPLATFORMINTEGRATION_WAYLAND_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtWaylandClient/qtwaylandclientglobal.h>
19#include <qpa/qplatformintegration.h>
20#include <QtCore/QScopedPointer>
21#include <QtCore/QMutex>
22#include <QtCore/private/qglobal_p.h>
23
24QT_BEGIN_NAMESPACE
25
26namespace QtWaylandClient {
27
28class QWaylandBuffer;
29class QWaylandDisplay;
30class QWaylandClientBufferIntegration;
31class QWaylandServerBufferIntegration;
32class QWaylandShellIntegration;
33class QWaylandInputDeviceIntegration;
34class QWaylandInputDevice;
35class QWaylandScreen;
36class QWaylandCursor;
37class QWaylandPlatformServices;
38
39class Q_WAYLANDCLIENT_EXPORT QWaylandIntegration : public QPlatformIntegration
40{
41public:
42 QWaylandIntegration();
43 ~QWaylandIntegration() override;
44
45 static QWaylandIntegration *instance() { return sInstance; }
46
47 bool init();
48
49 bool hasCapability(QPlatformIntegration::Capability cap) const override;
50 QPlatformWindow *createPlatformWindow(QWindow *window) const override;
51#if QT_CONFIG(opengl)
52 QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const override;
53#endif
54 QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const override;
55
56 QAbstractEventDispatcher *createEventDispatcher() const override;
57 void initialize() override;
58
59 QPlatformFontDatabase *fontDatabase() const override;
60
61 QPlatformNativeInterface *nativeInterface() const override;
62#if QT_CONFIG(clipboard)
63 QPlatformClipboard *clipboard() const override;
64#endif
65#if QT_CONFIG(draganddrop)
66 QPlatformDrag *drag() const override;
67#endif
68 QPlatformInputContext *inputContext() const override;
69
70 QVariant styleHint(StyleHint hint) const override;
71
72#if QT_CONFIG(accessibility)
73 QPlatformAccessibility *accessibility() const override;
74#endif
75
76 QPlatformServices *services() const override;
77
78 QWaylandDisplay *display() const;
79
80 Qt::KeyboardModifiers queryKeyboardModifiers() const override;
81
82 QList<int> possibleKeys(const QKeyEvent *event) const override;
83
84 QStringList themeNames() const override;
85
86 QPlatformTheme *createPlatformTheme(const QString &name) const override;
87
88#if QT_CONFIG(vulkan)
89 QPlatformVulkanInstance *createPlatformVulkanInstance(QVulkanInstance *instance) const override;
90#endif
91
92 void setApplicationBadge(qint64 number) override;
93
94 virtual QWaylandInputDevice *createInputDevice(QWaylandDisplay *display, int version, uint32_t id) const;
95 virtual QWaylandScreen *createPlatformScreen(QWaylandDisplay *waylandDisplay, int version, uint32_t id) const;
96 virtual QWaylandCursor *createPlatformCursor(QWaylandDisplay *display) const;
97
98 virtual QWaylandClientBufferIntegration *clientBufferIntegration() const;
99 virtual QWaylandServerBufferIntegration *serverBufferIntegration() const;
100 virtual QWaylandShellIntegration *shellIntegration() const;
101
102 void reconfigureInputContext();
103
104protected:
105 // NOTE: mDisplay *must* be destructed after mDrag and mClientBufferIntegration
106 // and mShellIntegration.
107 // Do not move this definition into the private section at the bottom.
108 QScopedPointer<QWaylandDisplay> mDisplay;
109
110protected:
111 void reset();
112 virtual QPlatformNativeInterface *createPlatformNativeInterface();
113
114 QScopedPointer<QWaylandClientBufferIntegration> mClientBufferIntegration;
115 QScopedPointer<QWaylandServerBufferIntegration> mServerBufferIntegration;
116 QScopedPointer<QWaylandShellIntegration> mShellIntegration;
117 QScopedPointer<QWaylandInputDeviceIntegration> mInputDeviceIntegration;
118
119 QScopedPointer<QPlatformInputContext> mInputContext;
120
121private:
122 void initializePlatform();
123 void initializeClientBufferIntegration();
124 void initializeServerBufferIntegration();
125 void initializeShellIntegration();
126 void initializeInputDeviceIntegration();
127 QWaylandShellIntegration *createShellIntegration(const QString& interfaceName);
128
129 QScopedPointer<QPlatformFontDatabase> mFontDb;
130#if QT_CONFIG(clipboard)
131 QScopedPointer<QPlatformClipboard> mClipboard;
132#endif
133#if QT_CONFIG(draganddrop)
134 QScopedPointer<QPlatformDrag> mDrag;
135#endif
136 QScopedPointer<QPlatformNativeInterface> mNativeInterface;
137#if QT_CONFIG(accessibility)
138 mutable QScopedPointer<QPlatformAccessibility> mAccessibility;
139#endif
140 QScopedPointer<QWaylandPlatformServices> mPlatformServices;
141 QMutex mClientBufferInitLock;
142 bool mClientBufferIntegrationInitialized = false;
143 bool mServerBufferIntegrationInitialized = false;
144 bool mShellIntegrationInitialized = false;
145
146 static QWaylandIntegration *sInstance;
147
148 friend class QWaylandDisplay;
149};
150
151}
152
153QT_END_NAMESPACE
154
155#endif
156

Provided by KDAB

Privacy Policy
Learn to use CMake with our Intro Training
Find out more

source code of qtwayland/src/client/qwaylandintegration_p.h