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 xx_session_manager_v1;
63 class xdg_system_bell_v1;
64 class xdg_toplevel_drag_manager_v1;
65 class wp_pointer_warp_v1;
66}
67
68namespace QtWaylandClient {
69
71
73class QWaylandInputDevice;
74class QWaylandBuffer;
75class QWaylandScreen;
76class QWaylandXdgOutputManagerV1;
77class QWaylandClientBufferIntegration;
78class QWaylandWindowManagerIntegration;
79class QWaylandDataDeviceManager;
80#if QT_CONFIG(clipboard)
82#endif
83#if QT_CONFIG(wayland_client_primary_selection)
85#endif
86#if QT_CONFIG(tabletevent)
88#endif
89class QWaylandPointerGestures;
90class QWaylandWindow;
91class QWaylandIntegration;
92class QWaylandHardwareIntegration;
93class QWaylandSessionManager;
94class QWaylandSurface;
95class QWaylandShellIntegration;
96class QWaylandCursor;
97class QWaylandCursorTheme;
98class EventThread;
99class ColorManager;
100
101typedef void (*RegistryListener)(void *data,
102 struct wl_registry *registry,
103 uint32_t id,
104 const QString &interface,
105 uint32_t version);
106
107class Q_WAYLANDCLIENT_EXPORT QWaylandDisplay : public QObject, public QtWayland::wl_registry {
109
110public:
113
114 bool initialize();
115
116#if QT_CONFIG(xkbcommon)
117 struct xkb_context *xkbContext() const { return mXkbContext.get(); }
118#endif
119
120 QList<QWaylandScreen *> screens() const { return mScreens; }
122 void ensureScreen();
123
126
127 struct wl_surface *createSurface(void *handle);
128 struct ::wl_region *createRegion(const QRegion &qregion);
131
135
136#if QT_CONFIG(cursor)
139#endif
140 struct wl_display *wl_display() const
141 {
142 return mDisplay;
143 }
144 struct ::wl_registry *wl_registry() { return object(); }
145
150
154#if QT_CONFIG(wayland_datadevice)
156 {
158 }
159#endif
160#if QT_CONFIG(clipboard)
162 {
164 }
165#endif
166#if QT_CONFIG(wayland_client_primary_selection)
168 {
170 }
171#endif
172#if QT_CONFIG(tabletevent)
174 {
175 return mGlobals.tabletManager.get();
176 }
177#endif
211 {
212 return mGlobals.viewporter.get();
213 }
227 {
228 return mGlobals.systemBell.get();
229 }
235 {
236 return mGlobals.colorManager.get();
237 }
239 {
240 return mGlobals.pointerWarp.get();
241 }
242
252 {
253 return mRegistryGlobals;
254 }
256
257 /* wl_registry_add_listener does not add but rather sets a listener, so this function is used
258 * to enable many listeners at once. */
261
263 {
264 return mGlobals.shm.get();
265 }
266
267 void forceRoundTrip();
268
269 bool supportsWindowDecoration() const;
270
275
281
283
284 bool isKeyboardAvailable() const;
286
287 void initEventThread();
288
289public Q_SLOTS:
290 void flushRequests();
291
293 void connected();
296
297private:
298 void checkWaylandError();
299 void reconnect();
300 void setupConnection();
301 void handleWaylandSync();
302 void requestWaylandSync();
303
305
306 struct Listener {
307 Listener() = default;
309 void* incomingData)
311 {}
312 RegistryListener listener = nullptr;
313 void *data = nullptr;
314 };
315 struct wl_display *mDisplay = nullptr;
325#if QT_CONFIG(cursor)
326 struct WaylandCursorTheme {
328 int pixelSize;
330 };
332
335 bool found;
336
337 QWaylandCursorTheme *theme() const noexcept
338 { return found ? position->theme.get() : nullptr; }
339 };
341 int pixelSize) const noexcept;
343#endif
344
345 struct GlobalHolder
346 {
349#if QT_CONFIG(wayland_datadevice)
351#endif
353#if QT_CONFIG(tabletevent)
355#endif
357#if QT_CONFIG(clipboard)
359#endif
360#if QT_CONFIG(wayland_client_primary_selection)
362#endif
379 } mGlobals;
380
381 int mFd = -1;
389 struct wl_callback *mSyncCallback = nullptr;
391 bool mWaylandTryReconnect = false;
392 bool mPreferWlrDataControl = false;
393
394 bool mWaylandInputContextRequested = [] () {
397 }();
400
403
404#if QT_CONFIG(xkbcommon)
406#endif
407
409};
410
411}
412
413QT_END_NAMESPACE
414
415#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