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
qwaylanddisplay_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// Copyright (C) 2024 Jie Liu <liujie01@kylinos.cn>
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
5#ifndef QWAYLANDDISPLAY_H
6#define QWAYLANDDISPLAY_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtCore/QList>
20#include <QtCore/QObject>
21#include <QtCore/QPointer>
22#include <QtCore/QRect>
23#include <QtCore/QMutex>
24#include <QtCore/QReadWriteLock>
25
26#include <QtCore/QWaitCondition>
27#include <QtCore/QLoggingCategory>
28
29#include <QtWaylandClient/private/qwayland-wayland.h>
30#include <QtWaylandClient/private/qtwaylandclientglobal_p.h>
31#include <QtWaylandClient/private/qwaylandshm_p.h>
32
33#include <qpa/qplatforminputcontextfactory_p.h>
34
35#if QT_CONFIG(xkbcommon)
36#include <QtGui/private/qxkbcommon_p.h>
37#endif
38
39struct wl_cursor_image;
40struct wp_viewport;
41
42QT_BEGIN_NAMESPACE
43
44#define WAYLAND_IM_KEY "wayland"
45
46class QAbstractEventDispatcher;
47class QSocketNotifier;
48class QPlatformScreen;
49class QPlatformPlaceholderScreen;
50
51namespace QtWayland {
52 class zwp_text_input_manager_v1;
53 class zwp_text_input_manager_v2;
54 class zwp_text_input_manager_v3;
55 class qt_text_input_method_manager_v1;
56 class wp_cursor_shape_manager_v1;
57 class wp_fractional_scale_manager_v1;
58 class wp_viewporter;
59 class xx_session_manager_v1;
60 class xdg_system_bell_v1;
61 class xdg_toplevel_drag_manager_v1;
62 class wp_pointer_warp_v1;
63}
64
65namespace QtWaylandClient {
66
68
70class QWaylandInputDevice;
71class QWaylandBuffer;
72class QWaylandScreen;
73class QWaylandXdgOutputManagerV1;
74class QWaylandClientBufferIntegration;
75class QWaylandWindowManagerIntegration;
76class QWaylandDataDeviceManager;
77#if QT_CONFIG(clipboard)
79#endif
80#if QT_CONFIG(wayland_client_primary_selection)
82#endif
83#if QT_CONFIG(tabletevent)
85#endif
86class QWaylandPointerGestures;
87class QWaylandWindow;
88class QWaylandIntegration;
89class QWaylandHardwareIntegration;
90class QWaylandSessionManager;
91class QWaylandSurface;
92class QWaylandShellIntegration;
93class QWaylandCursor;
94class QWaylandCursorTheme;
95class EventThread;
96class ColorManager;
97
98typedef void (*RegistryListener)(void *data,
99 struct wl_registry *registry,
100 uint32_t id,
101 const QString &interface,
102 uint32_t version);
103
104class Q_WAYLANDCLIENT_EXPORT QWaylandDisplay : public QObject, public QtWayland::wl_registry {
106
107public:
110
111 bool initialize();
112
113#if QT_CONFIG(xkbcommon)
114 struct xkb_context *xkbContext() const { return mXkbContext.get(); }
115#endif
116
117 QList<QWaylandScreen *> screens() const { return mScreens; }
119 void ensureScreen();
120
123
124 struct wl_surface *createSurface(void *handle);
125 struct ::wl_region *createRegion(const QRegion &qregion);
128
132
133#if QT_CONFIG(cursor)
136#endif
137 struct wl_display *wl_display() const
138 {
139 return mDisplay;
140 }
141 struct ::wl_registry *wl_registry() { return object(); }
142
147
151#if QT_CONFIG(wayland_datadevice)
153 {
155 }
156#endif
157#if QT_CONFIG(clipboard)
159 {
161 }
162#endif
163#if QT_CONFIG(wayland_client_primary_selection)
165 {
167 }
168#endif
169#if QT_CONFIG(tabletevent)
171 {
172 return mGlobals.tabletManager.get();
173 }
174#endif
208 {
209 return mGlobals.viewporter.get();
210 }
224 {
225 return mGlobals.systemBell.get();
226 }
232 {
233 return mGlobals.colorManager.get();
234 }
236 {
237 return mGlobals.pointerWarp.get();
238 }
239
249 {
250 return mRegistryGlobals;
251 }
253
254 /* wl_registry_add_listener does not add but rather sets a listener, so this function is used
255 * to enable many listeners at once. */
258
260 {
261 return mGlobals.shm.get();
262 }
263
264 void forceRoundTrip();
265
266 bool supportsWindowDecoration() const;
267
272
278
280
281 bool isKeyboardAvailable() const;
283
284 void initEventThread();
285
286public Q_SLOTS:
287 void flushRequests();
288
290 void connected();
293
294private:
295 void checkWaylandError();
296 void reconnect();
297 void setupConnection();
298 void handleWaylandSync();
299 void requestWaylandSync();
300
302
303 struct Listener {
304 Listener() = default;
306 void* incomingData)
308 {}
309 RegistryListener listener = nullptr;
310 void *data = nullptr;
311 };
312 struct wl_display *mDisplay = nullptr;
322#if QT_CONFIG(cursor)
323 struct WaylandCursorTheme {
325 int pixelSize;
327 };
329
332 bool found;
333
334 QWaylandCursorTheme *theme() const noexcept
335 { return found ? position->theme.get() : nullptr; }
336 };
338 int pixelSize) const noexcept;
340#endif
341
342 struct GlobalHolder
343 {
346#if QT_CONFIG(wayland_datadevice)
348#endif
350#if QT_CONFIG(tabletevent)
352#endif
354#if QT_CONFIG(clipboard)
356#endif
357#if QT_CONFIG(wayland_client_primary_selection)
359#endif
376 } mGlobals;
377
378 int mFd = -1;
386 struct wl_callback *mSyncCallback = nullptr;
388 bool mWaylandTryReconnect = false;
389 bool mPreferWlrDataControl = false;
390
391 bool mWaylandInputContextRequested = [] () {
394 }();
397
400
401#if QT_CONFIG(xkbcommon)
403#endif
404
406};
407
408}
409
410QT_END_NAMESPACE
411
412#endif // QWAYLANDDISPLAY_H
QT_DECLARE_EXPORTED_QT_LOGGING_CATEGORY(lcQpaWayland, Q_WAYLANDCLIENT_EXPORT)
#define WAYLAND_IM_KEY