Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
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
42
struct
wl_cursor_image;
43
struct
wp_viewport;
44
45
QT_BEGIN_NAMESPACE
46
47
#
define
WAYLAND_IM_KEY
"wayland"
48
49
class
QAbstractEventDispatcher;
50
class
QSocketNotifier;
51
class
QPlatformScreen;
52
class
QPlatformPlaceholderScreen;
53
54
namespace
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
69
namespace
QtWaylandClient
{
70
71
QT_DECLARE_EXPORTED_QT_LOGGING_CATEGORY
(
lcQpaWayland
, Q_WAYLANDCLIENT_EXPORT);
72
73
class
QWaylandAppMenuManager
;
74
class
QWaylandInputDevice;
75
class
QWaylandBuffer;
76
class
QWaylandScreen;
77
class
QWaylandXdgOutputManagerV1;
78
class
QWaylandClientBufferIntegration;
79
class
QWaylandWindowManagerIntegration;
80
class
QWaylandDataDeviceManager;
81
#
if
QT_CONFIG
(
clipboard
)
82
class
QWaylandDataControlManagerV1
;
83
#
endif
84
#
if
QT_CONFIG
(
wayland_client_primary_selection
)
85
class
QWaylandPrimarySelectionDeviceManagerV1
;
86
#
endif
87
#
if
QT_CONFIG
(
tabletevent
)
88
class
QWaylandTabletManagerV2
;
89
#
endif
90
class
QWaylandPointerGestures;
91
class
QWaylandWindow;
92
class
QWaylandIntegration;
93
class
QWaylandHardwareIntegration;
94
class
QWaylandSessionManager;
95
class
QWaylandSurface
;
96
class
QWaylandShellIntegration;
97
class
QWaylandCursor;
98
class
QWaylandCursorTheme;
99
class
EventThread
;
100
class
ColorManager
;
101
102
typedef
void
(*
RegistryListener
)(
void
*
data
,
103
struct
wl_registry *registry,
104
uint32_t id,
105
const
QString &interface,
106
uint32_t version);
107
108
class
Q_WAYLANDCLIENT_EXPORT
QWaylandDisplay
:
public
QObject
,
public
QtWayland
::
wl_registry
{
109
Q_OBJECT
110
111
public
:
112
QWaylandDisplay
(
QWaylandIntegration
*
waylandIntegration
,
QObject
*
parent
=
nullptr
);
113
~
QWaylandDisplay
(
void
)
override
;
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
; }
122
QPlatformPlaceholderScreen
*
placeholderScreen
()
const
{
return
mPlaceholderScreen
; }
123
void
ensureScreen
();
124
125
QWaylandScreen
*
screenForOutput
(
struct
wl_output
*
output
)
const
;
126
void
handleScreenInitialized
(
QWaylandScreen
*
screen
);
127
128
struct
wl_surface
*
createSurface
(
void
*
handle
);
129
struct
::
wl_region
*
createRegion
(
const
QRegion
&
qregion
);
130
struct
::
wl_subsurface
*
createSubSurface
(
QWaylandSurface
*
window
,
QWaylandSurface
*
parent
);
131
struct
::
wp_viewport
*
createViewport
(
QWaylandSurface
*
surface
);
132
133
QWaylandShellIntegration
*
shellIntegration
()
const
;
134
QWaylandClientBufferIntegration
*
clientBufferIntegration
()
const
;
135
QWaylandWindowManagerIntegration
*
windowManagerIntegration
()
const
;
136
137
#
if
QT_CONFIG
(
cursor
)
138
QWaylandCursor
*
waylandCursor
();
139
QWaylandCursorTheme
*
loadCursorTheme
(
const
QString
&
name
,
int
pixelSize
);
140
#
endif
141
struct
wl_display
*
wl_display
()
const
142
{
143
return
mDisplay
;
144
}
145
struct
::
wl_registry
*
wl_registry
() {
return
object
(); }
146
147
QtWayland
::
wl_compositor
*
compositor
()
148
{
149
return
mGlobals
.
compositor
.
get
();
150
}
151
152
QList
<
QWaylandInputDevice
*>
inputDevices
()
const
{
return
mInputDevices
; }
153
QWaylandInputDevice
*
defaultInputDevice
()
const
;
154
QWaylandInputDevice
*
currentInputDevice
()
const
{
return
defaultInputDevice
(); }
155
#
if
QT_CONFIG
(
wayland_datadevice
)
156
QWaylandDataDeviceManager
*
dndSelectionHandler
()
const
157
{
158
return
mGlobals
.
dndSelectionHandler
.
get
();
159
}
160
#
endif
161
#
if
QT_CONFIG
(
clipboard
)
162
QWaylandDataControlManagerV1
*
dataControlManager
()
const
163
{
164
return
mGlobals
.
dataControlManager
.
get
();
165
}
166
#
endif
167
#
if
QT_CONFIG
(
wayland_client_primary_selection
)
168
QWaylandPrimarySelectionDeviceManagerV1
*
primarySelectionManager
()
const
169
{
170
return
mGlobals
.
primarySelectionManager
.
get
();
171
}
172
#
endif
173
#
if
QT_CONFIG
(
tabletevent
)
174
QWaylandTabletManagerV2
*
tabletManager
()
const
175
{
176
return
mGlobals
.
tabletManager
.
get
();
177
}
178
#
endif
179
QWaylandPointerGestures
*
pointerGestures
()
const
180
{
181
return
mGlobals
.
pointerGestures
.
get
();
182
}
183
QtWayland
::
qt_text_input_method_manager_v1
*
textInputMethodManager
()
const
184
{
185
return
mGlobals
.
textInputMethodManager
.
get
();
186
}
187
QtWayland
::
zwp_text_input_manager_v1
*
textInputManagerv1
()
const
188
{
189
return
mGlobals
.
textInputManagerv1
.
get
();
190
}
191
QtWayland
::
zwp_text_input_manager_v2
*
textInputManagerv2
()
const
192
{
193
return
mGlobals
.
textInputManagerv2
.
get
();
194
}
195
QtWayland
::
zwp_text_input_manager_v3
*
textInputManagerv3
()
const
196
{
197
return
mGlobals
.
textInputManagerv3
.
get
();
198
}
199
QWaylandHardwareIntegration
*
hardwareIntegration
()
const
200
{
201
return
mGlobals
.
hardwareIntegration
.
get
();
202
}
203
QWaylandXdgOutputManagerV1
*
xdgOutputManager
()
const
204
{
205
return
mGlobals
.
xdgOutputManager
.
get
();
206
}
207
QtWayland
::
wp_fractional_scale_manager_v1
*
fractionalScaleManager
()
const
208
{
209
return
mGlobals
.
fractionalScaleManager
.
get
();
210
}
211
QtWayland
::
wp_viewporter
*
viewporter
()
const
212
{
213
return
mGlobals
.
viewporter
.
get
();
214
}
215
QtWayland
::
wp_cursor_shape_manager_v1
*
cursorShapeManager
()
const
216
{
217
return
mGlobals
.
cursorShapeManager
.
get
();
218
}
219
QtWayland
::
xdg_toplevel_drag_manager_v1
*
xdgToplevelDragManager
()
const
220
{
221
return
mGlobals
.
xdgToplevelDragManager
.
get
();
222
}
223
QtWayland
::
xdg_session_manager_v1
*
xdgSessionManager
()
const
224
{
225
return
mGlobals
.
xdgSessionManager
.
get
();
226
}
227
QtWayland
::
xdg_system_bell_v1
*
systemBell
()
const
228
{
229
return
mGlobals
.
systemBell
.
get
();
230
}
231
QWaylandAppMenuManager
*
appMenuManager
()
const
232
{
233
return
mGlobals
.
appMenuManager
.
get
();
234
}
235
ColorManager
*
colorManager
()
const
236
{
237
return
mGlobals
.
colorManager
.
get
();
238
}
239
QtWayland
::
wp_pointer_warp_v1
*
pointerWarp
()
const
240
{
241
return
mGlobals
.
pointerWarp
.
get
();
242
}
243
QtWayland
::
xx_cutouts_manager_v1
*
cutoutsManager
()
const
244
{
245
return
mGlobals
.
cutoutManager
.
get
();
246
}
247
248
struct
RegistryGlobal
{
249
uint32_t
id
;
250
QString
interface
;
251
uint32_t
version
;
252
struct
::
wl_registry
*
registry
=
nullptr
;
253
RegistryGlobal
(
uint32_t
id_
,
const
QString
&
interface_
,
uint32_t
version_
,
struct
::
wl_registry
*
registry_
)
254
:
id
(
id_
),
interface
(
interface_
),
version
(
version_
),
registry
(
registry_
) { }
255
};
256
QList
<
RegistryGlobal
>
globals
()
const
257
{
258
return
mRegistryGlobals
;
259
}
260
bool
hasRegistryGlobal
(
QStringView
interfaceName
)
const
;
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. */
264
void
addRegistryListener
(
RegistryListener
listener
,
void
*
data
);
265
void
removeListener
(
RegistryListener
listener
,
void
*
data
);
266
267
QWaylandShm
*
shm
()
const
268
{
269
return
mGlobals
.
shm
.
get
();
270
}
271
272
void
forceRoundTrip
();
273
274
bool
supportsWindowDecoration
()
const
;
275
276
uint32_t
lastInputSerial
()
const
{
return
mLastInputSerial
; }
277
QWaylandInputDevice
*
lastInputDevice
()
const
{
return
mLastInputDevice
; }
278
QWaylandWindow
*
lastInputWindow
()
const
;
279
QWaylandSurface
*
lastInputSurface
()
const
;
280
void
setLastInputDevice
(
QWaylandInputDevice
*
device
,
uint32_t
serial
,
QWaylandSurface
*
window
);
281
282
bool
isWindowActivated
(
const
QWaylandWindow
*
window
);
283
void
handleWindowActivated
(
QWaylandWindow
*
window
);
284
void
handleWindowDeactivated
(
QWaylandWindow
*
window
);
285
void
handleKeyboardFocusChanged
(
QWaylandInputDevice
*
inputDevice
);
286
void
handleWindowDestroyed
(
QWaylandWindow
*
window
);
287
288
wl_event_queue
*
frameEventQueue
() {
return
m_frameEventQueue
; };
289
290
bool
isKeyboardAvailable
()
const
;
291
bool
isWaylandInputContextRequested
()
const
;
292
293
void
initEventThread
();
294
295
QWaylandWindow
*
activeSubSurface
()
const
;
296
void
setActiveSubSurface
(
QWaylandWindow
*
window
);
297
298
public
Q_SLOTS
:
299
void
flushRequests
();
300
301
Q_SIGNALS
:
302
void
connected
();
303
void
globalAdded
(
const
RegistryGlobal
&
global
);
304
void
globalRemoved
(
const
RegistryGlobal
&
global
);
305
306
private
:
307
void
checkWaylandError
();
308
void
reconnect
();
309
void
setupConnection
();
310
void
handleWaylandSync
();
311
void
requestWaylandSync
();
312
313
void
checkTextInputProtocol
();
314
315
struct
Listener
{
316
Listener
() =
default
;
317
Listener
(
RegistryListener
incomingListener
,
318
void
*
incomingData
)
319
:
listener
(
incomingListener
),
data
(
incomingData
)
320
{}
321
RegistryListener
listener
=
nullptr
;
322
void
*
data
=
nullptr
;
323
};
324
struct
wl_display
*
mDisplay
=
nullptr
;
325
std
::
unique_ptr
<
QtWayland
::
wl_fixes
>
mFixes
;
326
std
::
unique_ptr
<
EventThread
>
m_eventThread
;
327
wl_event_queue
*
m_frameEventQueue
=
nullptr
;
328
std
::
unique_ptr
<
EventThread
>
m_frameEventQueueThread
;
329
QList
<
QWaylandScreen
*>
mWaitingScreens
;
330
QList
<
QWaylandScreen
*>
mScreens
;
331
QPlatformPlaceholderScreen
*
mPlaceholderScreen
=
nullptr
;
332
QList
<
QWaylandInputDevice
*>
mInputDevices
;
333
QList
<
Listener
>
mRegistryListeners
;
334
QWaylandIntegration
*
mWaylandIntegration
=
nullptr
;
335
#
if
QT_CONFIG
(
cursor
)
336
struct
WaylandCursorTheme
{
337
QString
name
;
338
int
pixelSize
= 0;
339
std
::
unique_ptr
<
QWaylandCursorTheme
>
theme
;
340
};
341
std
::
vector
<
WaylandCursorTheme
>
mCursorThemes
;
342
343
struct
FindExistingCursorThemeResult
{
344
std
::
vector
<
WaylandCursorTheme
>::
const_iterator
position
;
345
bool
found
=
false
;
346
347
QWaylandCursorTheme
*
theme
()
const
noexcept
348
{
return
found
?
position
->
theme
.
get
() :
nullptr
; }
349
};
350
FindExistingCursorThemeResult
findExistingCursorTheme
(
const
QString
&
name
,
351
int
pixelSize
)
const
noexcept
;
352
std
::
unique_ptr
<
QWaylandCursor
>
mCursor
;
353
#
endif
354
355
struct
GlobalHolder
356
{
357
std
::
unique_ptr
<
QtWayland
::
wl_compositor
>
compositor
;
358
std
::
unique_ptr
<
QWaylandShm
>
shm
;
359
#
if
QT_CONFIG
(
wayland_datadevice
)
360
std
::
unique_ptr
<
QWaylandDataDeviceManager
>
dndSelectionHandler
;
361
#
endif
362
std
::
unique_ptr
<
QtWayland
::
wl_subcompositor
>
subCompositor
;
363
#
if
QT_CONFIG
(
tabletevent
)
364
std
::
unique_ptr
<
QWaylandTabletManagerV2
>
tabletManager
;
365
#
endif
366
std
::
unique_ptr
<
QWaylandPointerGestures
>
pointerGestures
;
367
#
if
QT_CONFIG
(
clipboard
)
368
std
::
unique_ptr
<
QWaylandDataControlManagerV1
>
dataControlManager
;
369
#
endif
370
#
if
QT_CONFIG
(
wayland_client_primary_selection
)
371
std
::
unique_ptr
<
QWaylandPrimarySelectionDeviceManagerV1
>
primarySelectionManager
;
372
#
endif
373
std
::
unique_ptr
<
QtWayland
::
qt_text_input_method_manager_v1
>
textInputMethodManager
;
374
std
::
unique_ptr
<
QtWayland
::
zwp_text_input_manager_v1
>
textInputManagerv1
;
375
std
::
unique_ptr
<
QtWayland
::
zwp_text_input_manager_v2
>
textInputManagerv2
;
376
std
::
unique_ptr
<
QtWayland
::
zwp_text_input_manager_v3
>
textInputManagerv3
;
377
std
::
unique_ptr
<
QWaylandHardwareIntegration
>
hardwareIntegration
;
378
std
::
unique_ptr
<
QWaylandXdgOutputManagerV1
>
xdgOutputManager
;
379
std
::
unique_ptr
<
QtWayland
::
wp_viewporter
>
viewporter
;
380
std
::
unique_ptr
<
QtWayland
::
wp_fractional_scale_manager_v1
>
fractionalScaleManager
;
381
std
::
unique_ptr
<
QtWayland
::
wp_cursor_shape_manager_v1
>
cursorShapeManager
;
382
std
::
unique_ptr
<
QtWayland
::
xdg_session_manager_v1
>
xdgSessionManager
;
383
std
::
unique_ptr
<
QtWayland
::
xdg_system_bell_v1
>
systemBell
;
384
std
::
unique_ptr
<
QtWayland
::
xdg_toplevel_drag_manager_v1
>
xdgToplevelDragManager
;
385
std
::
unique_ptr
<
QWaylandWindowManagerIntegration
>
windowManagerIntegration
;
386
std
::
unique_ptr
<
QWaylandAppMenuManager
>
appMenuManager
;
387
std
::
unique_ptr
<
ColorManager
>
colorManager
;
388
std
::
unique_ptr
<
QtWayland
::
wp_pointer_warp_v1
>
pointerWarp
;
389
std
::
unique_ptr
<
QtWayland
::
xx_cutouts_manager_v1
>
cutoutManager
;
390
}
mGlobals
;
391
392
int
mFd
= -1;
393
int
mWritableNotificationFd
= -1;
394
QList
<
RegistryGlobal
>
mRegistryGlobals
;
395
uint32_t
mLastInputSerial
= 0;
396
QWaylandInputDevice
*
mLastInputDevice
=
nullptr
;
397
QPointer
<
QWaylandSurface
>
mLastInputSurface
;
398
QPointer
<
QWaylandWindow
>
mLastKeyboardFocus
;
399
QList
<
QWaylandWindow
*>
mActiveWindows
;
400
QPointer
<
QWaylandWindow
>
mActiveSubSurface
;
401
struct
wl_callback
*
mSyncCallback
=
nullptr
;
402
static
const
wl_callback_listener
syncCallbackListener
;
403
bool
mWaylandTryReconnect
=
false
;
404
bool
mPreferWlrDataControl
=
false
;
405
406
bool
mWaylandInputContextRequested
= [] () {
407
const
auto
requested
=
QPlatformInputContextFactory
::
requested
();
408
return
requested
.
isEmpty
() ||
requested
.
contains
(
QLatin1String
(
WAYLAND_IM_KEY
));
409
}();
410
QStringList
mTextInputManagerList
;
411
int
mTextInputManagerIndex
=
INT_MAX
;
412
413
void
registry_global
(
uint32_t
id
,
const
QString
&
interface
,
uint32_t
version
)
override
;
414
void
registry_global_remove
(
uint32_t
id
)
override
;
415
416
#
if
QT_CONFIG
(
xkbcommon
)
417
QXkbCommon
::
ScopedXKBContext
mXkbContext
;
418
#
endif
419
420
friend
class
QWaylandIntegration
;
421
};
422
423
}
424
425
QT_END_NAMESPACE
426
427
#
endif
// QWAYLANDDISPLAY_H
QtWaylandClient::ColorManager
Definition
qwaylandcolormanagement_p.h:33
QtWaylandClient::EventThread
Definition
qwaylanddisplay.cpp:81
QtWaylandClient::QWaylandAppMenuManager
Definition
qwaylandappmenu_p.h:36
QtWaylandClient::QWaylandDisplay
Definition
qwaylanddisplay_p.h:108
QtWaylandClient::QWaylandHardwareIntegration
Definition
qwaylandhardwareintegration_p.h:30
QtWaylandClient::QWaylandSurface
Definition
qwaylandsurface_p.h:37
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
QtWaylandClient
Definition
qwaylandclientextension.h:16
QtWaylandClient::QT_DECLARE_EXPORTED_QT_LOGGING_CATEGORY
QT_DECLARE_EXPORTED_QT_LOGGING_CATEGORY(lcQpaWayland, Q_WAYLANDCLIENT_EXPORT)
QtWayland
Definition
qwaylanddisplay_p.h:54
WAYLAND_IM_KEY
#define WAYLAND_IM_KEY
Definition
qwaylanddisplay_p.h:47
qtbase
src
plugins
platforms
wayland
qwaylanddisplay_p.h
Generated on
for Qt by
1.18.0