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
40struct wl_cursor_image;
41struct wp_viewport;
42
43QT_BEGIN_NAMESPACE
44
45#define WAYLAND_IM_KEY "wayland"
46
47class QAbstractEventDispatcher;
48class QSocketNotifier;
49class QPlatformScreen;
50class QPlatformPlaceholderScreen;
51
52namespace QtWayland {
53 class zwp_text_input_manager_v1;
54 class zwp_text_input_manager_v2;
55 class zwp_text_input_manager_v3;
56 class qt_text_input_method_manager_v1;
57 class wp_cursor_shape_manager_v1;
58 class wp_fractional_scale_manager_v1;
59 class wp_viewporter;
60 class xx_session_manager_v1;
61 class xdg_system_bell_v1;
62 class xdg_toplevel_drag_manager_v1;
63 class wp_pointer_warp_v1;
64}
65
66namespace QtWaylandClient {
67
69
71class QWaylandInputDevice;
72class QWaylandBuffer;
73class QWaylandScreen;
74class QWaylandXdgOutputManagerV1;
75class QWaylandClientBufferIntegration;
76class QWaylandWindowManagerIntegration;
77class QWaylandDataDeviceManager;
78#if QT_CONFIG(clipboard)
80#endif
81#if QT_CONFIG(wayland_client_primary_selection)
83#endif
84#if QT_CONFIG(tabletevent)
86#endif
87class QWaylandPointerGestures;
88class QWaylandWindow;
89class QWaylandIntegration;
90class QWaylandHardwareIntegration;
91class QWaylandSessionManager;
92class QWaylandSurface;
93class QWaylandShellIntegration;
94class QWaylandCursor;
95class QWaylandCursorTheme;
96class EventThread;
97class ColorManager;
98
99typedef void (*RegistryListener)(void *data,
100 struct wl_registry *registry,
101 uint32_t id,
102 const QString &interface,
103 uint32_t version);
104
105class Q_WAYLANDCLIENT_EXPORT QWaylandDisplay : public QObject, public QtWayland::wl_registry {
107
108public:
111
112 bool initialize();
113
114#if QT_CONFIG(xkbcommon)
115 struct xkb_context *xkbContext() const { return mXkbContext.get(); }
116#endif
117
118 QList<QWaylandScreen *> screens() const { return mScreens; }
120 void ensureScreen();
121
124
125 struct wl_surface *createSurface(void *handle);
126 struct ::wl_region *createRegion(const QRegion &qregion);
129
133
134#if QT_CONFIG(cursor)
137#endif
138 struct wl_display *wl_display() const
139 {
140 return mDisplay;
141 }
142 struct ::wl_registry *wl_registry() { return object(); }
143
148
152#if QT_CONFIG(wayland_datadevice)
154 {
156 }
157#endif
158#if QT_CONFIG(clipboard)
160 {
162 }
163#endif
164#if QT_CONFIG(wayland_client_primary_selection)
166 {
168 }
169#endif
170#if QT_CONFIG(tabletevent)
172 {
173 return mGlobals.tabletManager.get();
174 }
175#endif
209 {
210 return mGlobals.viewporter.get();
211 }
225 {
226 return mGlobals.systemBell.get();
227 }
233 {
234 return mGlobals.colorManager.get();
235 }
237 {
238 return mGlobals.pointerWarp.get();
239 }
240
250 {
251 return mRegistryGlobals;
252 }
254
255 /* wl_registry_add_listener does not add but rather sets a listener, so this function is used
256 * to enable many listeners at once. */
259
261 {
262 return mGlobals.shm.get();
263 }
264
265 void forceRoundTrip();
266
267 bool supportsWindowDecoration() const;
268
273
279
281
282 bool isKeyboardAvailable() const;
284
285 void initEventThread();
286
287public Q_SLOTS:
288 void flushRequests();
289
291 void connected();
294
295private:
296 void checkWaylandError();
297 void reconnect();
298 void setupConnection();
299 void handleWaylandSync();
300 void requestWaylandSync();
301
303
304 struct Listener {
305 Listener() = default;
307 void* incomingData)
309 {}
310 RegistryListener listener = nullptr;
311 void *data = nullptr;
312 };
313 struct wl_display *mDisplay = nullptr;
323#if QT_CONFIG(cursor)
324 struct WaylandCursorTheme {
326 int pixelSize;
328 };
330
333 bool found;
334
335 QWaylandCursorTheme *theme() const noexcept
336 { return found ? position->theme.get() : nullptr; }
337 };
339 int pixelSize) const noexcept;
341#endif
342
343 struct GlobalHolder
344 {
347#if QT_CONFIG(wayland_datadevice)
349#endif
351#if QT_CONFIG(tabletevent)
353#endif
355#if QT_CONFIG(clipboard)
357#endif
358#if QT_CONFIG(wayland_client_primary_selection)
360#endif
377 } mGlobals;
378
379 int mFd = -1;
387 struct wl_callback *mSyncCallback = nullptr;
389 bool mWaylandTryReconnect = false;
390 bool mPreferWlrDataControl = false;
391
392 bool mWaylandInputContextRequested = [] () {
395 }();
398
401
402#if QT_CONFIG(xkbcommon)
404#endif
405
407};
408
409}
410
411QT_END_NAMESPACE
412
413#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