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// Qt-Security score:significant reason:default
5
6#ifndef QWAYLANDDISPLAY_H
7#define QWAYLANDDISPLAY_H
8
9//
10// W A R N I N G
11// -------------
12//
13// This file is not part of the Qt API. It exists purely as an
14// implementation detail. This header file may change from version to
15// version without notice, or even be removed.
16//
17// We mean it.
18//
19
20#include <QtCore/QList>
21#include <QtCore/QObject>
22#include <QtCore/QPointer>
23#include <QtCore/QRect>
24#include <QtCore/QMutex>
25#include <QtCore/QReadWriteLock>
26
27#include <QtCore/QWaitCondition>
28#include <QtCore/QLoggingCategory>
29
30#include <QtWaylandClient/private/qwayland-wayland.h>
31#include <QtWaylandClient/private/qtwaylandclientglobal_p.h>
32#include <QtWaylandClient/private/qwaylandshm_p.h>
33
34#include <qpa/qplatforminputcontextfactory_p.h>
35
36#if QT_CONFIG(xkbcommon)
37#include <QtGui/private/qxkbcommon_p.h>
38#endif
39
40#include <memory>
41
42struct wl_cursor_image;
43struct wp_viewport;
44
45QT_BEGIN_NAMESPACE
46
47#define WAYLAND_IM_KEY "wayland"
48
49class QAbstractEventDispatcher;
50class QSocketNotifier;
51class QPlatformScreen;
52class QPlatformPlaceholderScreen;
53
54namespace QtWayland {
55 class zwp_text_input_manager_v1;
56 class zwp_text_input_manager_v2;
57 class zwp_text_input_manager_v3;
58 class qt_text_input_method_manager_v1;
59 class wp_cursor_shape_manager_v1;
60 class wp_fractional_scale_manager_v1;
61 class wp_viewporter;
62 class xdg_session_manager_v1;
63 class xdg_system_bell_v1;
64 class xdg_toplevel_drag_manager_v1;
65 class wp_pointer_warp_v1;
66 class xx_cutouts_manager_v1;
67}
68
69namespace QtWaylandClient {
70
72
74class QWaylandInputDevice;
75class QWaylandBuffer;
76class QWaylandScreen;
77class QWaylandXdgOutputManagerV1;
78class QWaylandClientBufferIntegration;
79class QWaylandWindowManagerIntegration;
80class QWaylandDataDeviceManager;
81#if QT_CONFIG(clipboard)
83#endif
84#if QT_CONFIG(wayland_client_primary_selection)
86#endif
87#if QT_CONFIG(tabletevent)
89#endif
90class QWaylandPointerGestures;
91class QWaylandWindow;
92class QWaylandIntegration;
93class QWaylandHardwareIntegration;
94class QWaylandSessionManager;
95class QWaylandSurface;
96class QWaylandShellIntegration;
97class QWaylandCursor;
98class QWaylandCursorTheme;
99class EventThread;
100class ColorManager;
101
102typedef void (*RegistryListener)(void *data,
103 struct wl_registry *registry,
104 uint32_t id,
105 const QString &interface,
106 uint32_t version);
107
108class Q_WAYLANDCLIENT_EXPORT QWaylandDisplay : public QObject, public QtWayland::wl_registry {
110
111public:
114
115 bool initialize();
116
117#if QT_CONFIG(xkbcommon)
118 struct xkb_context *xkbContext() const { return mXkbContext.get(); }
119#endif
120
121 QList<QWaylandScreen *> screens() const { return mScreens; }
123 void ensureScreen();
124
127
128 struct wl_surface *createSurface(void *handle);
129 struct ::wl_region *createRegion(const QRegion &qregion);
132
136
137#if QT_CONFIG(cursor)
140#endif
141 struct wl_display *wl_display() const
142 {
143 return mDisplay;
144 }
145 struct ::wl_registry *wl_registry() { return object(); }
146
151
155#if QT_CONFIG(wayland_datadevice)
157 {
159 }
160#endif
161#if QT_CONFIG(clipboard)
163 {
165 }
166#endif
167#if QT_CONFIG(wayland_client_primary_selection)
169 {
171 }
172#endif
173#if QT_CONFIG(tabletevent)
175 {
176 return mGlobals.tabletManager.get();
177 }
178#endif
212 {
213 return mGlobals.viewporter.get();
214 }
228 {
229 return mGlobals.systemBell.get();
230 }
236 {
237 return mGlobals.colorManager.get();
238 }
240 {
241 return mGlobals.pointerWarp.get();
242 }
247
257 {
258 return mRegistryGlobals;
259 }
261
262 /* wl_registry_add_listener does not add but rather sets a listener, so this function is used
263 * to enable many listeners at once. */
266
268 {
269 return mGlobals.shm.get();
270 }
271
272 void forceRoundTrip();
273
274 bool supportsWindowDecoration() const;
275
281
287
289
290 bool isKeyboardAvailable() const;
292
293 void initEventThread();
294
297
298public Q_SLOTS:
299 void flushRequests();
300
302 void connected();
305
306private:
307 void checkWaylandError();
308 void reconnect();
309 void setupConnection();
310 void handleWaylandSync();
311 void requestWaylandSync();
312
314
315 struct Listener {
316 Listener() = default;
318 void* incomingData)
320 {}
321 RegistryListener listener = nullptr;
322 void *data = nullptr;
323 };
324 struct wl_display *mDisplay = nullptr;
335#if QT_CONFIG(cursor)
336 struct WaylandCursorTheme {
338 int pixelSize = 0;
340 };
342
345 bool found = false;
346
347 QWaylandCursorTheme *theme() const noexcept
348 { return found ? position->theme.get() : nullptr; }
349 };
351 int pixelSize) const noexcept;
353#endif
354
355 struct GlobalHolder
356 {
359#if QT_CONFIG(wayland_datadevice)
361#endif
363#if QT_CONFIG(tabletevent)
365#endif
367#if QT_CONFIG(clipboard)
369#endif
370#if QT_CONFIG(wayland_client_primary_selection)
372#endif
390 } mGlobals;
391
392 int mFd = -1;
401 struct wl_callback *mSyncCallback = nullptr;
403 bool mWaylandTryReconnect = false;
404 bool mPreferWlrDataControl = false;
405
406 bool mWaylandInputContextRequested = [] () {
409 }();
412
415
416#if QT_CONFIG(xkbcommon)
418#endif
419
421};
422
423}
424
425QT_END_NAMESPACE
426
427#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