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 xdg_system_bell_v1;
60 class xdg_toplevel_drag_manager_v1;
61}
62
63namespace QtWaylandClient {
64
66
68class QWaylandInputDevice;
69class QWaylandBuffer;
70class QWaylandScreen;
71class QWaylandXdgOutputManagerV1;
72class QWaylandClientBufferIntegration;
73class QWaylandWindowManagerIntegration;
74class QWaylandDataDeviceManager;
75#if QT_CONFIG(clipboard)
77#endif
78#if QT_CONFIG(wayland_client_primary_selection)
80#endif
81#if QT_CONFIG(tabletevent)
83#endif
84class QWaylandPointerGestures;
85class QWaylandWindow;
86class QWaylandIntegration;
87class QWaylandHardwareIntegration;
88class QWaylandSurface;
89class QWaylandShellIntegration;
90class QWaylandCursor;
91class QWaylandCursorTheme;
92class EventThread;
93class ColorManager;
94
95typedef void (*RegistryListener)(void *data,
96 struct wl_registry *registry,
97 uint32_t id,
98 const QString &interface,
99 uint32_t version);
100
101class Q_WAYLANDCLIENT_EXPORT QWaylandDisplay : public QObject, public QtWayland::wl_registry {
103
104public:
107
108 bool initialize();
109
110#if QT_CONFIG(xkbcommon)
111 struct xkb_context *xkbContext() const { return mXkbContext.get(); }
112#endif
113
114 QList<QWaylandScreen *> screens() const { return mScreens; }
116 void ensureScreen();
117
120
121 struct wl_surface *createSurface(void *handle);
122 struct ::wl_region *createRegion(const QRegion &qregion);
125
129
130#if QT_CONFIG(cursor)
133#endif
134 struct wl_display *wl_display() const
135 {
136 return mDisplay;
137 }
138 struct ::wl_registry *wl_registry() { return object(); }
139
144
148#if QT_CONFIG(wayland_datadevice)
150 {
152 }
153#endif
154#if QT_CONFIG(clipboard)
156 {
158 }
159#endif
160#if QT_CONFIG(wayland_client_primary_selection)
162 {
164 }
165#endif
166#if QT_CONFIG(tabletevent)
168 {
169 return mGlobals.tabletManager.get();
170 }
171#endif
205 {
206 return mGlobals.viewporter.get();
207 }
217 {
218 return mGlobals.systemBell.get();
219 }
225 {
226 return mGlobals.colorManager.get();
227 }
228
238 {
239 return mRegistryGlobals;
240 }
242
243 /* wl_registry_add_listener does not add but rather sets a listener, so this function is used
244 * to enable many listeners at once. */
247
249 {
250 return mGlobals.shm.get();
251 }
252
253 void forceRoundTrip();
254
255 bool supportsWindowDecoration() const;
256
261
267
269
270 bool isKeyboardAvailable() const;
272
273 void initEventThread();
274
275public Q_SLOTS:
276 void blockingReadEvents();
277 void flushRequests();
278
280 void connected();
283
284private:
285 void checkWaylandError();
286 void reconnect();
287 void setupConnection();
288 void handleWaylandSync();
289 void requestWaylandSync();
290
292
293 struct Listener {
294 Listener() = default;
296 void* incomingData)
298 {}
299 RegistryListener listener = nullptr;
300 void *data = nullptr;
301 };
302 struct wl_display *mDisplay = nullptr;
312#if QT_CONFIG(cursor)
313 struct WaylandCursorTheme {
315 int pixelSize;
317 };
319
322 bool found;
323
324 QWaylandCursorTheme *theme() const noexcept
325 { return found ? position->theme.get() : nullptr; }
326 };
328 int pixelSize) const noexcept;
330#endif
331
332 struct GlobalHolder
333 {
336#if QT_CONFIG(wayland_datadevice)
338#endif
340#if QT_CONFIG(tabletevent)
342#endif
344#if QT_CONFIG(clipboard)
346#endif
347#if QT_CONFIG(wayland_client_primary_selection)
349#endif
364 } mGlobals;
365
366 int mFd = -1;
374 struct wl_callback *mSyncCallback = nullptr;
376 bool mWaylandTryReconnect = false;
377 bool mPreferWlrDataControl = false;
378
379 bool mWaylandInputContextRequested = [] () {
382 }();
385
388
389#if QT_CONFIG(xkbcommon)
391#endif
392
394};
395
396}
397
398QT_END_NAMESPACE
399
400#endif // QWAYLANDDISPLAY_H
Combined button and popup list for selecting options.
QT_DECLARE_EXPORTED_QT_LOGGING_CATEGORY(lcQpaWayland, Q_WAYLANDCLIENT_EXPORT)
#define WAYLAND_IM_KEY