Debian Codegraph @

src/client/qwaylanddisplay_p.h

raw symbols ◀ ▶ SCIP
3 Debian patches touch this file
1 /****************************************************************************
2 **
3 ** Copyright (C) 2016 The Qt Company Ltd.
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of the plugins of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see https://www.qt.io/terms-conditions. For further
15 ** information use the contact form at https://www.qt.io/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 3 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL3 included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 3 requirements
23 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24 **
25 ** GNU General Public License Usage
26 ** Alternatively, this file may be used under the terms of the GNU
27 ** General Public License version 2.0 or (at your option) the GNU General
28 ** Public license version 3 or any later version approved by the KDE Free
29 ** Qt Foundation. The licenses are as published by the Free Software
30 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31 ** included in the packaging of this file. Please review the following
32 ** information to ensure the GNU General Public License requirements will
33 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34 ** https://www.gnu.org/licenses/gpl-3.0.html.
35 **
36 ** $QT_END_LICENSE$
37 **
38 ****************************************************************************/
39
40 #ifndef QWAYLANDDISPLAY_H
41 #define QWAYLANDDISPLAY_H
42
43 //
44 // W A R N I N G
45 // -------------
46 //
47 // This file is not part of the Qt API. It exists purely as an
48 // implementation detail. This header file may change from version to
49 // version without notice, or even be removed.
50 //
51 // We mean it.
52 //
53
54 #include <QtCore/QObject>
55 #include <QtCore/QRect>
56 #include <QtCore/QPointer>
57 #include <QtCore/QVector>
58 #include <QtCore/QMutex>
59 #include <QtCore/QReadWriteLock>
60
61 #include <QtCore/QWaitCondition>
62 #include <QtCore/QLoggingCategory>
63
64 #include <QtWaylandClient/private/qwayland-wayland.h>
65 #include <QtWaylandClient/private/qtwaylandclientglobal_p.h>
66 #include <QtWaylandClient/private/qwaylandshm_p.h>
67
68 #include <qpa/qplatforminputcontextfactory_p.h>
69
70 #if QT_CONFIG(xkbcommon)
71 #include <QtXkbCommonSupport/private/qxkbcommon_p.h>
72 #endif
73
74 struct wl_cursor_image;
75
76 QT_BEGIN_NAMESPACE
77
78 class QAbstractEventDispatcher;
79 class QSocketNotifier;
80 class QPlatformScreen;
81 class QPlatformPlaceholderScreen;
82
83 namespace QtWayland {
84 class qt_surface_extension;
85 class zwp_text_input_manager_v2;
86 }
87
88 namespace QtWaylandClient {
89
90 Q_WAYLAND_CLIENT_EXPORT Q_DECLARE_LOGGING_CATEGORY(lcQpaWayland);
91
92 class QWaylandInputDevice;
93 class QWaylandBuffer;
94 class QWaylandScreen;
95 class QWaylandXdgOutputManagerV1;
96 class QWaylandClientBufferIntegration;
97 class QWaylandWindowManagerIntegration;
98 class QWaylandDataDeviceManager;
99 #if QT_CONFIG(wayland_client_primary_selection)
100 class QWaylandPrimarySelectionDeviceManagerV1;
101 #endif
102 #if QT_CONFIG(tabletevent)
103 class QWaylandTabletManagerV2;
104 #endif
105 class QWaylandTouchExtension;
106 class QWaylandQtKeyExtension;
107 class QWaylandWindow;
108 class QWaylandIntegration;
109 class QWaylandHardwareIntegration;
110 class QWaylandSurface;
111 class QWaylandShellIntegration;
112 class QWaylandCursor;
113 class QWaylandCursorTheme;
•114 class EventThread;
115
116 typedef void (*RegistryListener)(void *data,
117 struct wl_registry *registry,
118 uint32_t id,
119 const QString &interface,
120 uint32_t version);
121
122 class Q_WAYLAND_CLIENT_EXPORT QWaylandDisplay : public QObject, public QtWayland::wl_registry {
123 Q_OBJECT
124
125 public:
126 QWaylandDisplay(QWaylandIntegration *waylandIntegration);
127 ~QWaylandDisplay(void) override;
128
•129 void initialize();
130
131 #if QT_CONFIG(xkbcommon)
132 struct xkb_context *xkbContext() const { return mXkbContext.get(); }
133 #endif
134
135 QList<QWaylandScreen *> screens() const { return mScreens; }
136 QPlatformPlaceholderScreen *placeholderScreen() const { return mPlaceholderScreen; }
137 void ensureScreen();
138
139 QWaylandScreen *screenForOutput(struct wl_output *output) const;
140 void handleScreenInitialized(QWaylandScreen *screen);
141
142 struct wl_surface *createSurface(void *handle);
143 struct ::wl_region *createRegion(const QRegion &qregion);
144 struct ::wl_subsurface *createSubSurface(QWaylandWindow *window, QWaylandWindow *parent);
145
146 QWaylandShellIntegration *shellIntegration() const;
147 QWaylandClientBufferIntegration *clientBufferIntegration() const;
148 QWaylandWindowManagerIntegration *windowManagerIntegration() const;
149
150 #if QT_CONFIG(cursor)
151 QWaylandCursor *waylandCursor();
152 QWaylandCursorTheme *loadCursorTheme(const QString &name, int pixelSize);
153 #endif
154 struct wl_display *wl_display() const { return mDisplay; }
155 struct ::wl_registry *wl_registry() { return object(); }
156
157 const struct wl_compositor *wl_compositor() const { return mCompositor.object(); }
158 QtWayland::wl_compositor *compositor() { return &mCompositor; }
159 int compositorVersion() const { return mCompositorVersion; }
160
161 QList<QWaylandInputDevice *> inputDevices() const { return mInputDevices; }
162 QWaylandInputDevice *defaultInputDevice() const;
163 QWaylandInputDevice *currentInputDevice() const { return defaultInputDevice(); }
164 #if QT_CONFIG(wayland_datadevice)
165 QWaylandDataDeviceManager *dndSelectionHandler() const { return mDndSelectionHandler.data(); }
166 #endif
167 #if QT_CONFIG(wayland_client_primary_selection)
168 QWaylandPrimarySelectionDeviceManagerV1 *primarySelectionManager() const { return mPrimarySelectionManager.data(); }
169 #endif
170 QtWayland::qt_surface_extension *windowExtension() const { return mWindowExtension.data(); }
171 #if QT_CONFIG(tabletevent)
172 QWaylandTabletManagerV2 *tabletManager() const { return mTabletManager.data(); }
173 #endif
174 QWaylandTouchExtension *touchExtension() const { return mTouchExtension.data(); }
175 QtWayland::zwp_text_input_manager_v2 *textInputManager() const { return mTextInputManager.data(); }
176 QWaylandHardwareIntegration *hardwareIntegration() const { return mHardwareIntegration.data(); }
177 QWaylandXdgOutputManagerV1 *xdgOutputManager() const { return mXdgOutputManager.data(); }
178
179 struct RegistryGlobal {
180 uint32_t id;
181 QString interface;
182 uint32_t version;
183 struct ::wl_registry *registry = nullptr;
184 RegistryGlobal(uint32_t id_, const QString &interface_, uint32_t version_, struct ::wl_registry *registry_)
185 : id(id_), interface(interface_), version(version_), registry(registry_) { }
186 };
187 QList<RegistryGlobal> globals() const { return mGlobals; }
188 bool hasRegistryGlobal(QStringView interfaceName) const;
189
190 /* wl_registry_add_listener does not add but rather sets a listener, so this function is used
191 * to enable many listeners at once. */
192 void addRegistryListener(RegistryListener listener, void *data);
193 void removeListener(RegistryListener listener, void *data);
194
195 QWaylandShm *shm() const { return mShm.data(); }
196
197 static uint32_t currentTimeMillisec();
198
199 void forceRoundTrip();
200
201 bool supportsWindowDecoration() const;
202
203 uint32_t lastInputSerial() const { return mLastInputSerial; }
204 QWaylandInputDevice *lastInputDevice() const { return mLastInputDevice; }
205 QWaylandWindow *lastInputWindow() const;
206 void setLastInputDevice(QWaylandInputDevice *device, uint32_t serial, QWaylandWindow *window);
207
208 bool isWindowActivated(const QWaylandWindow *window);
209 void handleWindowActivated(QWaylandWindow *window);
210 void handleWindowDeactivated(QWaylandWindow *window);
211 void handleKeyboardFocusChanged(QWaylandInputDevice *inputDevice);
212 void handleWindowDestroyed(QWaylandWindow *window);
213
•214 wl_event_queue *frameEventQueue() { return m_frameEventQueue; };
215
216 bool isKeyboardAvailable() const;
•217
218 void initEventThread();
•219 public slots:
220 void blockingReadEvents();
221 void flushRequests();
222
223 private:
224 void waitForScreens();
225 void checkError() const;
226
227 void handleWaylandSync();
228 void requestWaylandSync();
229
230 struct Listener {
231 Listener() = default;
232 Listener(RegistryListener incomingListener,
233 void* incomingData)
234 : listener(incomingListener), data(incomingData)
235 {}
236 RegistryListener listener = nullptr;
237 void *data = nullptr;
238 };
239
240 struct wl_display *mDisplay = nullptr;
•241 QScopedPointer<EventThread> m_eventThread;
242 wl_event_queue *m_frameEventQueue = nullptr;
243 QScopedPointer<EventThread> m_frameEventQueueThread;
244 QtWayland::wl_compositor mCompositor;
245 QScopedPointer<QWaylandShm> mShm;
246 QList<QWaylandScreen *> mWaitingScreens;
247 QList<QWaylandScreen *> mScreens;
248 QPlatformPlaceholderScreen *mPlaceholderScreen = nullptr;
249 QList<QWaylandInputDevice *> mInputDevices;
250 QList<Listener> mRegistryListeners;
251 QWaylandIntegration *mWaylandIntegration = nullptr;
252 #if QT_CONFIG(cursor)
253 QMap<std::pair<QString, int>, QWaylandCursorTheme *> mCursorThemes; // theme name and size
254 QScopedPointer<QWaylandCursor> mCursor;
255 #endif
256 #if QT_CONFIG(wayland_datadevice)
257 QScopedPointer<QWaylandDataDeviceManager> mDndSelectionHandler;
258 #endif
259 QScopedPointer<QtWayland::qt_surface_extension> mWindowExtension;
260 QScopedPointer<QtWayland::wl_subcompositor> mSubCompositor;
261 QScopedPointer<QWaylandTouchExtension> mTouchExtension;
262 QScopedPointer<QWaylandQtKeyExtension> mQtKeyExtension;
263 QScopedPointer<QWaylandWindowManagerIntegration> mWindowManagerIntegration;
264 #if QT_CONFIG(tabletevent)
265 QScopedPointer<QWaylandTabletManagerV2> mTabletManager;
266 #endif
267 #if QT_CONFIG(wayland_client_primary_selection)
268 QScopedPointer<QWaylandPrimarySelectionDeviceManagerV1> mPrimarySelectionManager;
269 #endif
270 QScopedPointer<QtWayland::zwp_text_input_manager_v2> mTextInputManager;
271 QScopedPointer<QWaylandHardwareIntegration> mHardwareIntegration;
272 QScopedPointer<QWaylandXdgOutputManagerV1> mXdgOutputManager;
273 QSocketNotifier *mReadNotifier = nullptr;
274 int mFd = -1;
275 int mWritableNotificationFd = -1;
276 QList<RegistryGlobal> mGlobals;
277 int mCompositorVersion = -1;
278 uint32_t mLastInputSerial = 0;
279 QWaylandInputDevice *mLastInputDevice = nullptr;
280 QPointer<QWaylandWindow> mLastInputWindow;
281 QPointer<QWaylandWindow> mLastKeyboardFocus;
•282 QList<QWaylandWindow *> mActiveWindows;
283 struct wl_callback *mSyncCallback = nullptr;
284 static const wl_callback_listener syncCallbackListener;
285
286 bool mClientSideInputContextRequested = !QPlatformInputContextFactory::requested().isNull();
287
288 void registry_global(uint32_t id, const QString &interface, uint32_t version) override;
289 void registry_global_remove(uint32_t id) override;
290
291 #if QT_CONFIG(xkbcommon)
292 QXkbCommon::ScopedXKBContext mXkbContext;
293 #endif
294
295 friend class QWaylandIntegration;
296 };
297
298 }
299
300 QT_END_NAMESPACE
301
302 #endif // QWAYLANDDISPLAY_H