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
qwaylandintegration.cpp
Go to the documentation of this file.
1
// Copyright (C) 2016 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
// Qt-Security score:significant reason:default
4
5
#
include
"qwaylandintegration_p.h"
6
7
#
include
"qwaylanddisplay_p.h"
8
#
include
"qwaylandshmwindow_p.h"
9
#
include
"qwaylandinputdevice_p.h"
10
#
include
"qwaylandinputcontext_p.h"
11
#
include
"qwaylandinputmethodcontext_p.h"
12
#
include
"qwaylandshmbackingstore_p.h"
13
#
include
"qwaylandnativeinterface_p.h"
14
#
if
QT_CONFIG
(
clipboard
)
15
#
include
"qwaylandclipboard_p.h"
16
#
endif
17
#
include
"qwaylanddnd_p.h"
18
#
include
"qwaylandwindowmanagerintegration_p.h"
19
#
include
"qwaylandplatformservices_p.h"
20
#
include
"qwaylandscreen_p.h"
21
#
include
"qwaylandcursor_p.h"
22
23
#
if
defined
(
Q_OS_MACOS
)
24
#
include
<
QtGui
/
private
/
qcoretextfontdatabase_p
.
h
>
25
#
include
<
QtGui
/
private
/
qfontengine_coretext_p
.
h
>
26
#
else
27
#
include
<
QtGui
/
private
/
qgenericunixfontdatabase_p
.
h
>
28
#
endif
29
#
include
<
QtGui
/
private
/
qgenericunixeventdispatcher_p
.
h
>
30
#
include
<
QtGui
/
private
/
qgenericunixtheme_p
.
h
>
31
32
#
include
<
QtGui
/
private
/
qguiapplication_p
.
h
>
33
34
#
include
<
qpa
/
qwindowsysteminterface
.
h
>
35
#
include
<
qpa
/
qplatformcursor
.
h
>
36
#
include
<
QtGui
/
QSurfaceFormat
>
37
#
if
QT_CONFIG
(
opengl
)
38
#
include
<
QtGui
/
QOpenGLContext
>
39
#
endif
// QT_CONFIG(opengl)
40
#
include
<
QSocketNotifier
>
41
42
#
include
<
qpa
/
qplatforminputcontextfactory_p
.
h
>
43
#
include
<
qpa
/
qplatformaccessibility
.
h
>
44
#
include
<
qpa
/
qplatforminputcontext
.
h
>
45
46
#
include
"qwaylandhardwareintegration_p.h"
47
#
include
"qwaylandclientbufferintegration_p.h"
48
#
include
"qwaylandclientbufferintegrationfactory_p.h"
49
50
#
include
"qwaylandserverbufferintegration_p.h"
51
#
include
"qwaylandserverbufferintegrationfactory_p.h"
52
#
include
"qwaylandshellsurface_p.h"
53
54
#
include
"qwaylandshellintegration_p.h"
55
#
include
"qwaylandshellintegrationfactory_p.h"
56
57
#
include
"qwaylandinputdeviceintegration_p.h"
58
#
include
"qwaylandinputdeviceintegrationfactory_p.h"
59
#
include
"qwaylandwindow_p.h"
60
#
include
"qwaylandsessionmanager_p.h"
61
62
#
include
<
QtWaylandClient
/
private
/
qwayland
-
xdg
-
system
-
bell
-
v1
.
h
>
63
64
#
if
QT_CONFIG
(
accessibility_atspi_bridge
)
65
#
include
<
QtGui
/
private
/
qspiaccessiblebridge_p
.
h
>
66
#
endif
67
68
#
if
QT_CONFIG
(
xkbcommon
)
69
#
include
<
QtGui
/
private
/
qxkbcommon_p
.
h
>
70
#
endif
71
72
#
if
QT_CONFIG
(
vulkan
)
73
#
include
"qwaylandvulkaninstance_p.h"
74
#
include
"qwaylandvulkanwindow_p.h"
75
#
endif
76
77
QT_BEGIN_NAMESPACE
78
79
using
namespace
Qt::StringLiterals;
80
81
namespace
QtWaylandClient
{
82
83
QWaylandIntegration
*
QWaylandIntegration
::
sInstance
=
nullptr
;
84
85
QWaylandIntegration
::
QWaylandIntegration
(
const
QString
&
platformName
)
86
#
if
defined
(
Q_OS_MACOS
)
87
:
mFontDb
(
new
QCoreTextFontDatabaseEngineFactory
<
QCoreTextFontEngine
>)
88
#
else
89
:
mPlatformName
(
platformName
),
mFontDb
(
new
QGenericUnixFontDatabase
())
90
#
endif
91
{
92
QCoreApplication
::
setAttribute
(
Qt
::
AA_CompressHighFrequencyEvents
);
93
94
mDisplay
.
reset
(
new
QWaylandDisplay
(
this
));
95
mPlatformServices
.
reset
(
new
QWaylandPlatformServices
(
mDisplay
.
get
()));
96
97
QWaylandWindow
::
fixedToplevelPositions
=
98
!
qEnvironmentVariableIsSet
(
"QT_WAYLAND_DISABLE_FIXED_POSITIONS"
);
99
100
sInstance
=
this
;
101
if
(
platformName
!=
"wayland"_L1
)
102
initializeClientBufferIntegration
();
103
}
104
105
QWaylandIntegration
::~
QWaylandIntegration
()
106
{
107
sInstance
=
nullptr
;
108
}
109
110
bool
QWaylandIntegration
::
init
()
111
{
112
return
mDisplay
->
initialize
();
113
}
114
115
QPlatformNativeInterface
*
QWaylandIntegration
::
nativeInterface
()
const
116
{
117
return
mNativeInterface
.
get
();
118
}
119
120
bool
QWaylandIntegration
::
hasCapability
(
QPlatformIntegration
::
Capability
cap
)
const
121
{
122
switch
(
cap
) {
123
case
ThreadedPixmaps
:
return
true
;
124
case
OpenGL
:
125
return
mDisplay
->
clientBufferIntegration
();
126
case
ThreadedOpenGL
:
127
return
mDisplay
->
clientBufferIntegration
() &&
mDisplay
->
clientBufferIntegration
()->
supportsThreadedOpenGL
();
128
case
BufferQueueingOpenGL
:
129
return
true
;
130
case
MultipleWindows
:
131
case
NonFullScreenWindows
:
132
case
ChildWindows
:
133
return
true
;
134
case
WindowActivation
:
135
return
true
;
136
case
ScreenWindowGrabbing
:
// whether QScreen::grabWindow() is supported
137
return
false
;
138
case
OffscreenSurface
:
139
return
mDisplay
->
clientBufferIntegration
()
140
&&
mDisplay
->
clientBufferIntegration
()->
canCreatePlatformOffscreenSurface
();
141
default
:
return
QPlatformIntegration
::
hasCapability
(
cap
);
142
}
143
}
144
145
QPlatformWindow
*
QWaylandIntegration
::
createPlatformWindow
(
QWindow
*
window
)
const
146
{
147
if
(
window
->
surfaceType
() ==
QWindow
::
OpenGLSurface
148
&&
mDisplay
->
clientBufferIntegration
())
149
return
mDisplay
->
clientBufferIntegration
()->
createEglWindow
(
window
);
150
151
#
if
QT_CONFIG
(
vulkan
)
152
if
(
window
->
surfaceType
() ==
QSurface
::
VulkanSurface
)
153
return
new
QWaylandVulkanWindow
(
window
,
mDisplay
.
get
());
154
#
endif
// QT_CONFIG(vulkan)
155
156
return
new
QWaylandShmWindow
(
window
,
mDisplay
.
get
());
157
}
158
159
#
if
QT_CONFIG
(
opengl
)
&&
QT_CONFIG
(
egl
)
160
QPlatformOpenGLContext
*
QWaylandIntegration
::
createPlatformOpenGLContext
(
QOpenGLContext
*
context
)
const
161
{
162
if
(
mDisplay
->
clientBufferIntegration
())
163
return
mDisplay
->
clientBufferIntegration
()->
createPlatformOpenGLContext
(
context
->
format
(),
context
->
shareHandle
());
164
return
nullptr
;
165
}
166
167
QPlatformOffscreenSurface
*
QWaylandIntegration
::
createPlatformOffscreenSurface
(
QOffscreenSurface
*
surface
)
const
168
{
169
if
(
mDisplay
->
clientBufferIntegration
())
170
return
mDisplay
->
clientBufferIntegration
()->
createPlatformOffscreenSurface
(
surface
);
171
return
nullptr
;
172
}
173
174
QOpenGLContext
*
QWaylandIntegration
::
createOpenGLContext
(
EGLContext
context
,
EGLDisplay
contextDisplay
,
QOpenGLContext
*
shareContext
)
const
175
{
176
return
mClientBufferIntegration
->
createOpenGLContext
(
context
,
contextDisplay
,
shareContext
);
177
}
178
#
endif
// opengl
179
180
QPlatformBackingStore
*
QWaylandIntegration
::
createPlatformBackingStore
(
QWindow
*
window
)
const
181
{
182
return
new
QWaylandShmBackingStore
(
window
,
mDisplay
.
get
());
183
}
184
185
QAbstractEventDispatcher
*
QWaylandIntegration
::
createEventDispatcher
()
const
186
{
187
return
createUnixEventDispatcher
();
188
}
189
190
QPlatformNativeInterface
*
QWaylandIntegration
::
createPlatformNativeInterface
()
191
{
192
return
new
QWaylandNativeInterface
(
this
);
193
}
194
195
// Support platform specific initialization
196
void
QWaylandIntegration
::
initializePlatform
()
197
{
198
mDisplay
->
initEventThread
();
199
200
mNativeInterface
.
reset
(
createPlatformNativeInterface
());
201
initializeInputDeviceIntegration
();
202
#
if
QT_CONFIG
(
clipboard
)
203
mClipboard
.
reset
(
new
QWaylandClipboard
(
mDisplay
.
get
()));
204
#
endif
205
#
if
QT_CONFIG
(
draganddrop
)
206
mDrag
.
reset
(
new
QWaylandDrag
(
mDisplay
.
get
()));
207
#
endif
208
209
reconfigureInputContext
();
210
}
211
212
void
QWaylandIntegration
::
initialize
()
213
{
214
initializePlatform
();
215
216
// Call this after initializing event thread for QWaylandDisplay::flushRequests()
217
QAbstractEventDispatcher
*
dispatcher
=
QGuiApplicationPrivate
::
eventDispatcher
;
218
QObject
::
connect
(
dispatcher
, &
QAbstractEventDispatcher
::
aboutToBlock
,
mDisplay
.
get
(), &
QWaylandDisplay
::
flushRequests
);
219
QObject
::
connect
(
dispatcher
, &
QAbstractEventDispatcher
::
awake
,
mDisplay
.
get
(), &
QWaylandDisplay
::
flushRequests
);
220
221
// Qt does not support running with no screens
222
mDisplay
->
ensureScreen
();
223
}
224
225
QPlatformFontDatabase
*
QWaylandIntegration
::
fontDatabase
()
const
226
{
227
return
mFontDb
.
get
();
228
}
229
230
#
if
QT_CONFIG
(
clipboard
)
231
QPlatformClipboard
*
QWaylandIntegration
::
clipboard
()
const
232
{
233
return
mClipboard
.
get
();
234
}
235
#
endif
236
237
#
if
QT_CONFIG
(
draganddrop
)
238
QPlatformDrag
*
QWaylandIntegration
::
drag
()
const
239
{
240
return
mDrag
.
get
();
241
}
242
#
endif
// draganddrop
243
244
QPlatformInputContext
*
QWaylandIntegration
::
inputContext
()
const
245
{
246
return
mInputContext
.
get
();
247
}
248
249
QVariant
QWaylandIntegration
::
styleHint
(
StyleHint
hint
)
const
250
{
251
if
(
hint
==
ShowIsFullScreen
&&
mDisplay
->
windowManagerIntegration
())
252
return
mDisplay
->
windowManagerIntegration
()->
showIsFullScreen
();
253
254
return
QPlatformIntegration
::
styleHint
(
hint
);
255
}
256
257
#
if
QT_CONFIG
(
accessibility
)
258
QPlatformAccessibility
*
QWaylandIntegration
::
accessibility
()
const
259
{
260
if
(!
mAccessibility
) {
261
#
if
QT_CONFIG
(
accessibility_atspi_bridge
)
262
Q_ASSERT_X
(
QCoreApplication
::
eventDispatcher
(),
"QWaylandIntegration"
,
263
"Initializing accessibility without event-dispatcher!"
);
264
mAccessibility
.
reset
(
new
QSpiAccessibleBridge
());
265
#
else
266
mAccessibility
.
reset
(
new
QPlatformAccessibility
());
267
#
endif
268
}
269
return
mAccessibility
.
get
();
270
}
271
#
endif
272
273
QPlatformServices
*
QWaylandIntegration
::
services
()
const
274
{
275
return
mPlatformServices
.
get
();
276
}
277
278
QWaylandDisplay
*
QWaylandIntegration
::
display
()
const
279
{
280
return
mDisplay
.
get
();
281
}
282
283
Qt
::
KeyboardModifiers
QWaylandIntegration
::
queryKeyboardModifiers
()
const
284
{
285
if
(
auto
*
seat
=
mDisplay
->
currentInputDevice
();
seat
&&
seat
->
keyboardFocus
()) {
286
return
seat
->
modifiers
();
287
}
288
return
Qt
::
NoModifier
;
289
}
290
291
QList
<
int
>
QWaylandIntegration
::
possibleKeys
(
const
QKeyEvent
*
event
)
const
292
{
293
if
(
auto
*
seat
=
mDisplay
->
currentInputDevice
())
294
return
seat
->
possibleKeys
(
event
);
295
return
{};
296
}
297
298
QStringList
QWaylandIntegration
::
themeNames
()
const
299
{
300
return
QGenericUnixTheme
::
themeNames
();
301
}
302
303
QPlatformTheme
*
QWaylandIntegration
::
createPlatformTheme
(
const
QString
&
name
)
const
304
{
305
return
QGenericUnixTheme
::
createUnixTheme
(
name
);
306
}
307
308
QWaylandScreen
*
QWaylandIntegration
::
createPlatformScreen
(
QWaylandDisplay
*
waylandDisplay
,
int
version
,
uint32_t
id
)
const
309
{
310
return
new
QWaylandScreen
(
waylandDisplay
,
version
,
id
);
311
}
312
313
QWaylandCursor
*
QWaylandIntegration
::
createPlatformCursor
(
QWaylandDisplay
*
display
)
const
314
{
315
return
new
QWaylandCursor
(
display
);
316
}
317
318
#
if
QT_CONFIG
(
vulkan
)
319
QPlatformVulkanInstance
*
QWaylandIntegration
::
createPlatformVulkanInstance
(
QVulkanInstance
*
instance
)
const
320
{
321
return
new
QWaylandVulkanInstance
(
instance
);
322
}
323
#
endif
// QT_CONFIG(vulkan)
324
325
// May be called from non-GUI threads
326
QWaylandClientBufferIntegration
*
QWaylandIntegration
::
clientBufferIntegration
()
const
327
{
328
// Do an inexpensive check first to avoid locking whenever possible
329
if
(
Q_UNLIKELY
(!
mClientBufferIntegrationInitialized
))
330
const_cast
<
QWaylandIntegration
*>(
this
)->
initializeClientBufferIntegration
();
331
332
Q_ASSERT
(
mClientBufferIntegrationInitialized
);
333
bool
isValid
=
mClientBufferIntegration
&&
mClientBufferIntegration
->
isValid
();
334
return
isValid
?
mClientBufferIntegration
.
get
() :
nullptr
;
335
}
336
337
QWaylandServerBufferIntegration
*
QWaylandIntegration
::
serverBufferIntegration
()
const
338
{
339
if
(!
mServerBufferIntegrationInitialized
)
340
const_cast
<
QWaylandIntegration
*>(
this
)->
initializeServerBufferIntegration
();
341
342
return
mServerBufferIntegration
.
get
();
343
}
344
345
QWaylandShellIntegration
*
QWaylandIntegration
::
shellIntegration
()
const
346
{
347
if
(!
mShellIntegrationInitialized
)
348
const_cast
<
QWaylandIntegration
*>(
this
)->
initializeShellIntegration
();
349
350
return
mShellIntegration
.
get
();
351
}
352
353
// May be called from non-GUI threads
354
void
QWaylandIntegration
::
initializeClientBufferIntegration
()
355
{
356
QMutexLocker
lock
(&
mClientBufferInitLock
);
357
if
(
mClientBufferIntegrationInitialized
)
358
return
;
359
360
QString
targetKey
=
QString
::
fromLocal8Bit
(
qgetenv
(
"QT_WAYLAND_CLIENT_BUFFER_INTEGRATION"
));
361
if
(
mPlatformName
==
"wayland-egl"_L1
)
362
targetKey
=
"wayland-egl"_L1
;
363
else
if
(
mPlatformName
==
"wayland-brcm"_L1
)
364
targetKey
=
"brcm"_L1
;
365
366
if
(
targetKey
.
isEmpty
()) {
367
if
(
mDisplay
->
hardwareIntegration
()
368
&&
mDisplay
->
hardwareIntegration
()->
clientBufferIntegration
() !=
QLatin1String
(
"wayland-eglstream-controller"
)
369
&&
mDisplay
->
hardwareIntegration
()->
clientBufferIntegration
() !=
QLatin1String
(
"linux-dmabuf-v1"
)
370
&&
mDisplay
->
hardwareIntegration
()->
clientBufferIntegration
() !=
QLatin1String
(
"linux-dmabuf-unstable-v1"
)) {
371
targetKey
=
mDisplay
->
hardwareIntegration
()->
clientBufferIntegration
();
372
}
else
{
373
targetKey
=
QLatin1String
(
"wayland-egl"
);
374
}
375
}
376
377
if
(
targetKey
.
isEmpty
()) {
378
qWarning
(
"Failed to determine what client buffer integration to use"
);
379
}
else
{
380
QStringList
keys
=
QWaylandClientBufferIntegrationFactory
::
keys
();
381
qCDebug
(
lcQpaWayland
) <<
"Available client buffer integrations:"
<<
keys
;
382
383
if
(
keys
.
contains
(
targetKey
))
384
mClientBufferIntegration
.
reset
(
QWaylandClientBufferIntegrationFactory
::
create
(
targetKey
,
QStringList
()));
385
386
if
(
mClientBufferIntegration
) {
387
qCDebug
(
lcQpaWayland
) <<
"Initializing client buffer integration"
<<
targetKey
;
388
mClientBufferIntegration
->
initialize
(
mDisplay
.
get
());
389
}
else
{
390
qCWarning
(
lcQpaWayland
) <<
"Failed to load client buffer integration:"
<<
targetKey
;
391
qCWarning
(
lcQpaWayland
) <<
"Available client buffer integrations:"
<<
keys
;
392
}
393
}
394
395
// This must be set last to make sure other threads don't use the
396
// integration before initialization is complete.
397
mClientBufferIntegrationInitialized
=
true
;
398
}
399
400
void
QWaylandIntegration
::
initializeServerBufferIntegration
()
401
{
402
mServerBufferIntegrationInitialized
=
true
;
403
404
QString
targetKey
=
QString
::
fromLocal8Bit
(
qgetenv
(
"QT_WAYLAND_SERVER_BUFFER_INTEGRATION"
));
405
406
if
(
targetKey
.
isEmpty
() &&
mDisplay
->
hardwareIntegration
())
407
targetKey
=
mDisplay
->
hardwareIntegration
()->
serverBufferIntegration
();
408
409
if
(
targetKey
.
isEmpty
()) {
410
qWarning
(
"Failed to determine what server buffer integration to use"
);
411
return
;
412
}
413
414
QStringList
keys
=
QWaylandServerBufferIntegrationFactory
::
keys
();
415
qCDebug
(
lcQpaWayland
) <<
"Available server buffer integrations:"
<<
keys
;
416
417
if
(
keys
.
contains
(
targetKey
))
418
mServerBufferIntegration
.
reset
(
QWaylandServerBufferIntegrationFactory
::
create
(
targetKey
,
QStringList
()));
419
420
if
(
mServerBufferIntegration
) {
421
qCDebug
(
lcQpaWayland
) <<
"Initializing server buffer integration"
<<
targetKey
;
422
mServerBufferIntegration
->
initialize
(
mDisplay
.
get
());
423
}
else
{
424
qCWarning
(
lcQpaWayland
) <<
"Failed to load server buffer integration: "
<<
targetKey
;
425
qCWarning
(
lcQpaWayland
) <<
"Available server buffer integrations:"
<<
keys
;
426
}
427
}
428
429
void
QWaylandIntegration
::
initializeShellIntegration
()
430
{
431
mShellIntegrationInitialized
=
true
;
432
433
QByteArray
integrationNames
=
qgetenv
(
"QT_WAYLAND_SHELL_INTEGRATION"
);
434
QString
targetKeys
=
QString
::
fromLocal8Bit
(
integrationNames
);
435
436
QStringList
preferredShells
;
437
if
(!
targetKeys
.
isEmpty
()) {
438
preferredShells
=
targetKeys
.
split
(
QLatin1Char
(
';'
));
439
}
else
{
440
preferredShells
<<
QLatin1String
(
"xdg-shell"
);
441
preferredShells
<<
QLatin1String
(
"wl-shell"
) <<
QLatin1String
(
"ivi-shell"
);
442
preferredShells
<<
QLatin1String
(
"qt-shell"
);
443
}
444
445
for
(
const
QString
&
preferredShell
:
std
::
as_const
(
preferredShells
)) {
446
mShellIntegration
.
reset
(
createShellIntegration
(
preferredShell
));
447
if
(
mShellIntegration
) {
448
qCDebug
(
lcQpaWayland
,
"Using the '%s' shell integration"
,
qPrintable
(
preferredShell
));
449
break
;
450
}
451
}
452
453
if
(!
mShellIntegration
) {
454
qCWarning
(
lcQpaWayland
) <<
"Loading shell integration failed."
;
455
qCWarning
(
lcQpaWayland
) <<
"Attempted to load the following shells"
<<
preferredShells
;
456
}
457
458
QWindowSystemInterfacePrivate
::
TabletEvent
::
setPlatformSynthesizesMouse
(
false
);
459
}
460
461
QWaylandInputDevice
*
QWaylandIntegration
::
createInputDevice
(
QWaylandDisplay
*
display
,
int
version
,
uint32_t
id
)
const
462
{
463
if
(
mInputDeviceIntegration
) {
464
return
mInputDeviceIntegration
->
createInputDevice
(
display
,
version
,
id
);
465
}
466
return
new
QWaylandInputDevice
(
display
,
version
,
id
);
467
}
468
469
void
QWaylandIntegration
::
initializeInputDeviceIntegration
()
470
{
471
QByteArray
integrationName
=
qgetenv
(
"QT_WAYLAND_INPUTDEVICE_INTEGRATION"
);
472
QString
targetKey
=
QString
::
fromLocal8Bit
(
integrationName
);
473
474
if
(
targetKey
.
isEmpty
()) {
475
return
;
476
}
477
478
QStringList
keys
=
QWaylandInputDeviceIntegrationFactory
::
keys
();
479
if
(
keys
.
contains
(
targetKey
)) {
480
mInputDeviceIntegration
.
reset
(
QWaylandInputDeviceIntegrationFactory
::
create
(
targetKey
,
QStringList
()));
481
qDebug
(
"Using the '%s' input device integration"
,
qPrintable
(
targetKey
));
482
}
else
{
483
qWarning
(
"Wayland inputdevice integration '%s' not found, using default"
,
qPrintable
(
targetKey
));
484
}
485
}
486
487
void
QWaylandIntegration
::
reconfigureInputContext
()
488
{
489
if
(!
mDisplay
) {
490
// This function can be called from QWaylandDisplay::registry_global() when we
491
// are in process of constructing QWaylandDisplay. Configuring input context
492
// in that case is done by calling reconfigureInputContext() from QWaylandIntegration
493
// constructor, after QWaylandDisplay has been constructed.
494
return
;
495
}
496
497
auto
requested
=
QPlatformInputContextFactory
::
requested
();
498
if
(
requested
.
contains
(
QLatin1String
(
"qtvirtualkeyboard"
)))
499
qCWarning
(
lcQpaWayland
) <<
"qtvirtualkeyboard currently is not supported at client-side,"
500
" use QT_IM_MODULES=qtvirtualkeyboard at compositor-side."
;
501
502
if
(
mDisplay
->
isWaylandInputContextRequested
()
503
&& !
requested
.
contains
(
QLatin1String
(
WAYLAND_IM_KEY
)))
504
requested
.
append
(
QLatin1String
(
WAYLAND_IM_KEY
));
505
506
const
QString
defaultInputContext
(
QStringLiteral
(
"compose"
));
507
if
(!
requested
.
contains
(
defaultInputContext
))
508
requested
.
append
(
defaultInputContext
);
509
510
for
(
const
QString
&
imKey
:
requested
) {
511
if
(
imKey
==
QLatin1String
(
WAYLAND_IM_KEY
)) {
512
Q_ASSERT
(
mDisplay
->
isWaylandInputContextRequested
());
513
if
(
mDisplay
->
textInputMethodManager
() !=
nullptr
)
514
mInputContext
.
reset
(
new
QWaylandInputMethodContext
(
mDisplay
.
get
()));
515
else
if
(
mDisplay
->
textInputManagerv1
() !=
nullptr
516
||
mDisplay
->
textInputManagerv2
() !=
nullptr
517
||
mDisplay
->
textInputManagerv3
() !=
nullptr
)
518
mInputContext
.
reset
(
new
QWaylandInputContext
(
mDisplay
.
get
()));
519
}
else
{
520
mInputContext
.
reset
(
QPlatformInputContextFactory
::
create
(
imKey
));
521
}
522
523
if
(
mInputContext
&&
mInputContext
->
isValid
())
524
break
;
525
}
526
527
#
if
QT_CONFIG
(
xkbcommon
)
528
QXkbCommon
::
setXkbContext
(
mInputContext
.
get
(),
mDisplay
->
xkbContext
());
529
if
(
QWaylandInputContext
*
waylandInput
=
qobject_cast
<
QWaylandInputContext
*>(
mInputContext
.
get
())) {
530
waylandInput
->
setXkbContext
(
mDisplay
->
xkbContext
());
531
}
532
#
endif
533
534
qCDebug
(
lcQpaWayland
) <<
"using input method:"
<< (
inputContext
() ?
inputContext
()->
metaObject
()->
className
() :
"<none>"
);
535
}
536
537
QWaylandShellIntegration
*
QWaylandIntegration
::
createShellIntegration
(
const
QString
&
integrationName
)
538
{
539
if
(
QWaylandShellIntegrationFactory
::
keys
().
contains
(
integrationName
)) {
540
return
QWaylandShellIntegrationFactory
::
create
(
integrationName
,
mDisplay
.
get
());
541
}
else
{
542
qCWarning
(
lcQpaWayland
) <<
"No shell integration named"
<<
integrationName
<<
"found"
;
543
return
nullptr
;
544
}
545
}
546
547
#
ifndef
QT_NO_SESSIONMANAGER
548
QPlatformSessionManager
*
QWaylandIntegration
::
createPlatformSessionManager
(
const
QString
&
id
,
const
QString
&
key
)
const
549
{
550
Q_UNUSED
(
key
);
551
return
new
QWaylandSessionManager
(
mDisplay
.
get
(),
id
);
552
}
553
#
endif
554
555
void
QWaylandIntegration
::
reset
()
556
{
557
mServerBufferIntegration
.
reset
();
558
mServerBufferIntegrationInitialized
=
false
;
559
560
mInputDeviceIntegration
.
reset
();
561
562
mClientBufferIntegration
.
reset
();
563
mClientBufferIntegrationInitialized
=
false
;
564
}
565
566
void
QWaylandIntegration
::
setApplicationBadge
(
qint64
number
)
567
{
568
mPlatformServices
->
setApplicationBadge
(
number
);
569
}
570
571
void
QWaylandIntegration
::
beep
()
const
572
{
573
if
(
auto
bell
=
mDisplay
->
systemBell
()) {
574
bell
->
ring
(
nullptr
);
575
}
576
}
577
578
}
579
580
QT_END_NAMESPACE
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
QtWaylandClient
Definition
qwaylandclientextension.h:16
WAYLAND_IM_KEY
#define WAYLAND_IM_KEY
Definition
qwaylanddisplay_p.h:47
qtbase
src
plugins
platforms
wayland
qwaylandintegration.cpp
Generated on
for Qt by
1.16.1