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
return
true
;
133
case
WindowActivation
:
134
return
true
;
135
case
ScreenWindowGrabbing
:
// whether QScreen::grabWindow() is supported
136
return
false
;
137
case
OffscreenSurface
:
138
return
mDisplay
->
clientBufferIntegration
()
139
&&
mDisplay
->
clientBufferIntegration
()->
canCreatePlatformOffscreenSurface
();
140
default
:
return
QPlatformIntegration
::
hasCapability
(
cap
);
141
}
142
}
143
144
QPlatformWindow
*
QWaylandIntegration
::
createPlatformWindow
(
QWindow
*
window
)
const
145
{
146
if
(
window
->
surfaceType
() ==
QWindow
::
OpenGLSurface
147
&&
mDisplay
->
clientBufferIntegration
())
148
return
mDisplay
->
clientBufferIntegration
()->
createEglWindow
(
window
);
149
150
#
if
QT_CONFIG
(
vulkan
)
151
if
(
window
->
surfaceType
() ==
QSurface
::
VulkanSurface
)
152
return
new
QWaylandVulkanWindow
(
window
,
mDisplay
.
get
());
153
#
endif
// QT_CONFIG(vulkan)
154
155
return
new
QWaylandShmWindow
(
window
,
mDisplay
.
get
());
156
}
157
158
#
if
QT_CONFIG
(
opengl
)
159
QPlatformOpenGLContext
*
QWaylandIntegration
::
createPlatformOpenGLContext
(
QOpenGLContext
*
context
)
const
160
{
161
if
(
mDisplay
->
clientBufferIntegration
())
162
return
mDisplay
->
clientBufferIntegration
()->
createPlatformOpenGLContext
(
context
->
format
(),
context
->
shareHandle
());
163
return
nullptr
;
164
}
165
166
QPlatformOffscreenSurface
*
QWaylandIntegration
::
createPlatformOffscreenSurface
(
QOffscreenSurface
*
surface
)
const
167
{
168
if
(
mDisplay
->
clientBufferIntegration
())
169
return
mDisplay
->
clientBufferIntegration
()->
createPlatformOffscreenSurface
(
surface
);
170
return
nullptr
;
171
}
172
173
QOpenGLContext
*
QWaylandIntegration
::
createOpenGLContext
(
EGLContext
context
,
EGLDisplay
contextDisplay
,
QOpenGLContext
*
shareContext
)
const
174
{
175
return
mClientBufferIntegration
->
createOpenGLContext
(
context
,
contextDisplay
,
shareContext
);
176
}
177
#
endif
// opengl
178
179
QPlatformBackingStore
*
QWaylandIntegration
::
createPlatformBackingStore
(
QWindow
*
window
)
const
180
{
181
return
new
QWaylandShmBackingStore
(
window
,
mDisplay
.
get
());
182
}
183
184
QAbstractEventDispatcher
*
QWaylandIntegration
::
createEventDispatcher
()
const
185
{
186
return
createUnixEventDispatcher
();
187
}
188
189
QPlatformNativeInterface
*
QWaylandIntegration
::
createPlatformNativeInterface
()
190
{
191
return
new
QWaylandNativeInterface
(
this
);
192
}
193
194
// Support platform specific initialization
195
void
QWaylandIntegration
::
initializePlatform
()
196
{
197
mDisplay
->
initEventThread
();
198
199
mNativeInterface
.
reset
(
createPlatformNativeInterface
());
200
initializeInputDeviceIntegration
();
201
#
if
QT_CONFIG
(
clipboard
)
202
mClipboard
.
reset
(
new
QWaylandClipboard
(
mDisplay
.
get
()));
203
#
endif
204
#
if
QT_CONFIG
(
draganddrop
)
205
mDrag
.
reset
(
new
QWaylandDrag
(
mDisplay
.
get
()));
206
#
endif
207
208
reconfigureInputContext
();
209
}
210
211
void
QWaylandIntegration
::
initialize
()
212
{
213
initializePlatform
();
214
215
// Call this after initializing event thread for QWaylandDisplay::flushRequests()
216
QAbstractEventDispatcher
*
dispatcher
=
QGuiApplicationPrivate
::
eventDispatcher
;
217
QObject
::
connect
(
dispatcher
,
SIGNAL
(
aboutToBlock
()),
mDisplay
.
get
(),
SLOT
(
flushRequests
()));
218
QObject
::
connect
(
dispatcher
,
SIGNAL
(
awake
()),
mDisplay
.
get
(),
SLOT
(
flushRequests
()));
219
220
// Qt does not support running with no screens
221
mDisplay
->
ensureScreen
();
222
}
223
224
QPlatformFontDatabase
*
QWaylandIntegration
::
fontDatabase
()
const
225
{
226
return
mFontDb
.
get
();
227
}
228
229
#
if
QT_CONFIG
(
clipboard
)
230
QPlatformClipboard
*
QWaylandIntegration
::
clipboard
()
const
231
{
232
return
mClipboard
.
get
();
233
}
234
#
endif
235
236
#
if
QT_CONFIG
(
draganddrop
)
237
QPlatformDrag
*
QWaylandIntegration
::
drag
()
const
238
{
239
return
mDrag
.
get
();
240
}
241
#
endif
// draganddrop
242
243
QPlatformInputContext
*
QWaylandIntegration
::
inputContext
()
const
244
{
245
return
mInputContext
.
get
();
246
}
247
248
QVariant
QWaylandIntegration
::
styleHint
(
StyleHint
hint
)
const
249
{
250
if
(
hint
==
ShowIsFullScreen
&&
mDisplay
->
windowManagerIntegration
())
251
return
mDisplay
->
windowManagerIntegration
()->
showIsFullScreen
();
252
253
return
QPlatformIntegration
::
styleHint
(
hint
);
254
}
255
256
#
if
QT_CONFIG
(
accessibility
)
257
QPlatformAccessibility
*
QWaylandIntegration
::
accessibility
()
const
258
{
259
if
(!
mAccessibility
) {
260
#
if
QT_CONFIG
(
accessibility_atspi_bridge
)
261
Q_ASSERT_X
(
QCoreApplication
::
eventDispatcher
(),
"QWaylandIntegration"
,
262
"Initializing accessibility without event-dispatcher!"
);
263
mAccessibility
.
reset
(
new
QSpiAccessibleBridge
());
264
#
else
265
mAccessibility
.
reset
(
new
QPlatformAccessibility
());
266
#
endif
267
}
268
return
mAccessibility
.
get
();
269
}
270
#
endif
271
272
QPlatformServices
*
QWaylandIntegration
::
services
()
const
273
{
274
return
mPlatformServices
.
get
();
275
}
276
277
QWaylandDisplay
*
QWaylandIntegration
::
display
()
const
278
{
279
return
mDisplay
.
get
();
280
}
281
282
Qt
::
KeyboardModifiers
QWaylandIntegration
::
queryKeyboardModifiers
()
const
283
{
284
if
(
auto
*
seat
=
mDisplay
->
currentInputDevice
();
seat
&&
seat
->
keyboardFocus
()) {
285
return
seat
->
modifiers
();
286
}
287
return
Qt
::
NoModifier
;
288
}
289
290
QList
<
int
>
QWaylandIntegration
::
possibleKeys
(
const
QKeyEvent
*
event
)
const
291
{
292
if
(
auto
*
seat
=
mDisplay
->
currentInputDevice
())
293
return
seat
->
possibleKeys
(
event
);
294
return
{};
295
}
296
297
QStringList
QWaylandIntegration
::
themeNames
()
const
298
{
299
return
QGenericUnixTheme
::
themeNames
();
300
}
301
302
QPlatformTheme
*
QWaylandIntegration
::
createPlatformTheme
(
const
QString
&
name
)
const
303
{
304
return
QGenericUnixTheme
::
createUnixTheme
(
name
);
305
}
306
307
QWaylandScreen
*
QWaylandIntegration
::
createPlatformScreen
(
QWaylandDisplay
*
waylandDisplay
,
int
version
,
uint32_t
id
)
const
308
{
309
return
new
QWaylandScreen
(
waylandDisplay
,
version
,
id
);
310
}
311
312
QWaylandCursor
*
QWaylandIntegration
::
createPlatformCursor
(
QWaylandDisplay
*
display
)
const
313
{
314
return
new
QWaylandCursor
(
display
);
315
}
316
317
#
if
QT_CONFIG
(
vulkan
)
318
QPlatformVulkanInstance
*
QWaylandIntegration
::
createPlatformVulkanInstance
(
QVulkanInstance
*
instance
)
const
319
{
320
return
new
QWaylandVulkanInstance
(
instance
);
321
}
322
#
endif
// QT_CONFIG(vulkan)
323
324
// May be called from non-GUI threads
325
QWaylandClientBufferIntegration
*
QWaylandIntegration
::
clientBufferIntegration
()
const
326
{
327
// Do an inexpensive check first to avoid locking whenever possible
328
if
(
Q_UNLIKELY
(!
mClientBufferIntegrationInitialized
))
329
const_cast
<
QWaylandIntegration
*>(
this
)->
initializeClientBufferIntegration
();
330
331
Q_ASSERT
(
mClientBufferIntegrationInitialized
);
332
bool
isValid
=
mClientBufferIntegration
&&
mClientBufferIntegration
->
isValid
();
333
return
isValid
?
mClientBufferIntegration
.
get
() :
nullptr
;
334
}
335
336
QWaylandServerBufferIntegration
*
QWaylandIntegration
::
serverBufferIntegration
()
const
337
{
338
if
(!
mServerBufferIntegrationInitialized
)
339
const_cast
<
QWaylandIntegration
*>(
this
)->
initializeServerBufferIntegration
();
340
341
return
mServerBufferIntegration
.
get
();
342
}
343
344
QWaylandShellIntegration
*
QWaylandIntegration
::
shellIntegration
()
const
345
{
346
if
(!
mShellIntegrationInitialized
)
347
const_cast
<
QWaylandIntegration
*>(
this
)->
initializeShellIntegration
();
348
349
return
mShellIntegration
.
get
();
350
}
351
352
// May be called from non-GUI threads
353
void
QWaylandIntegration
::
initializeClientBufferIntegration
()
354
{
355
QMutexLocker
lock
(&
mClientBufferInitLock
);
356
if
(
mClientBufferIntegrationInitialized
)
357
return
;
358
359
QString
targetKey
=
QString
::
fromLocal8Bit
(
qgetenv
(
"QT_WAYLAND_CLIENT_BUFFER_INTEGRATION"
));
360
if
(
mPlatformName
==
"wayland-egl"_L1
)
361
targetKey
=
"wayland-egl"_L1
;
362
else
if
(
mPlatformName
==
"wayland-brcm"_L1
)
363
targetKey
=
"brcm"_L1
;
364
365
if
(
targetKey
.
isEmpty
()) {
366
if
(
mDisplay
->
hardwareIntegration
()
367
&&
mDisplay
->
hardwareIntegration
()->
clientBufferIntegration
() !=
QLatin1String
(
"wayland-eglstream-controller"
)
368
&&
mDisplay
->
hardwareIntegration
()->
clientBufferIntegration
() !=
QLatin1String
(
"linux-dmabuf-v1"
)
369
&&
mDisplay
->
hardwareIntegration
()->
clientBufferIntegration
() !=
QLatin1String
(
"linux-dmabuf-unstable-v1"
)) {
370
targetKey
=
mDisplay
->
hardwareIntegration
()->
clientBufferIntegration
();
371
}
else
{
372
targetKey
=
QLatin1String
(
"wayland-egl"
);
373
}
374
}
375
376
if
(
targetKey
.
isEmpty
()) {
377
qWarning
(
"Failed to determine what client buffer integration to use"
);
378
}
else
{
379
QStringList
keys
=
QWaylandClientBufferIntegrationFactory
::
keys
();
380
qCDebug
(
lcQpaWayland
) <<
"Available client buffer integrations:"
<<
keys
;
381
382
if
(
keys
.
contains
(
targetKey
))
383
mClientBufferIntegration
.
reset
(
QWaylandClientBufferIntegrationFactory
::
create
(
targetKey
,
QStringList
()));
384
385
if
(
mClientBufferIntegration
) {
386
qCDebug
(
lcQpaWayland
) <<
"Initializing client buffer integration"
<<
targetKey
;
387
mClientBufferIntegration
->
initialize
(
mDisplay
.
get
());
388
}
else
{
389
qCWarning
(
lcQpaWayland
) <<
"Failed to load client buffer integration:"
<<
targetKey
;
390
qCWarning
(
lcQpaWayland
) <<
"Available client buffer integrations:"
<<
keys
;
391
}
392
}
393
394
// This must be set last to make sure other threads don't use the
395
// integration before initialization is complete.
396
mClientBufferIntegrationInitialized
=
true
;
397
}
398
399
void
QWaylandIntegration
::
initializeServerBufferIntegration
()
400
{
401
mServerBufferIntegrationInitialized
=
true
;
402
403
QString
targetKey
=
QString
::
fromLocal8Bit
(
qgetenv
(
"QT_WAYLAND_SERVER_BUFFER_INTEGRATION"
));
404
405
if
(
targetKey
.
isEmpty
() &&
mDisplay
->
hardwareIntegration
())
406
targetKey
=
mDisplay
->
hardwareIntegration
()->
serverBufferIntegration
();
407
408
if
(
targetKey
.
isEmpty
()) {
409
qWarning
(
"Failed to determine what server buffer integration to use"
);
410
return
;
411
}
412
413
QStringList
keys
=
QWaylandServerBufferIntegrationFactory
::
keys
();
414
qCDebug
(
lcQpaWayland
) <<
"Available server buffer integrations:"
<<
keys
;
415
416
if
(
keys
.
contains
(
targetKey
))
417
mServerBufferIntegration
.
reset
(
QWaylandServerBufferIntegrationFactory
::
create
(
targetKey
,
QStringList
()));
418
419
if
(
mServerBufferIntegration
) {
420
qCDebug
(
lcQpaWayland
) <<
"Initializing server buffer integration"
<<
targetKey
;
421
mServerBufferIntegration
->
initialize
(
mDisplay
.
get
());
422
}
else
{
423
qCWarning
(
lcQpaWayland
) <<
"Failed to load server buffer integration: "
<<
targetKey
;
424
qCWarning
(
lcQpaWayland
) <<
"Available server buffer integrations:"
<<
keys
;
425
}
426
}
427
428
void
QWaylandIntegration
::
initializeShellIntegration
()
429
{
430
mShellIntegrationInitialized
=
true
;
431
432
QByteArray
integrationNames
=
qgetenv
(
"QT_WAYLAND_SHELL_INTEGRATION"
);
433
QString
targetKeys
=
QString
::
fromLocal8Bit
(
integrationNames
);
434
435
QStringList
preferredShells
;
436
if
(!
targetKeys
.
isEmpty
()) {
437
preferredShells
=
targetKeys
.
split
(
QLatin1Char
(
';'
));
438
}
else
{
439
preferredShells
<<
QLatin1String
(
"xdg-shell"
);
440
preferredShells
<<
QLatin1String
(
"wl-shell"
) <<
QLatin1String
(
"ivi-shell"
);
441
preferredShells
<<
QLatin1String
(
"qt-shell"
);
442
}
443
444
for
(
const
QString
&
preferredShell
:
std
::
as_const
(
preferredShells
)) {
445
mShellIntegration
.
reset
(
createShellIntegration
(
preferredShell
));
446
if
(
mShellIntegration
) {
447
qCDebug
(
lcQpaWayland
,
"Using the '%s' shell integration"
,
qPrintable
(
preferredShell
));
448
break
;
449
}
450
}
451
452
if
(!
mShellIntegration
) {
453
qCWarning
(
lcQpaWayland
) <<
"Loading shell integration failed."
;
454
qCWarning
(
lcQpaWayland
) <<
"Attempted to load the following shells"
<<
preferredShells
;
455
}
456
457
QWindowSystemInterfacePrivate
::
TabletEvent
::
setPlatformSynthesizesMouse
(
false
);
458
}
459
460
QWaylandInputDevice
*
QWaylandIntegration
::
createInputDevice
(
QWaylandDisplay
*
display
,
int
version
,
uint32_t
id
)
const
461
{
462
if
(
mInputDeviceIntegration
) {
463
return
mInputDeviceIntegration
->
createInputDevice
(
display
,
version
,
id
);
464
}
465
return
new
QWaylandInputDevice
(
display
,
version
,
id
);
466
}
467
468
void
QWaylandIntegration
::
initializeInputDeviceIntegration
()
469
{
470
QByteArray
integrationName
=
qgetenv
(
"QT_WAYLAND_INPUTDEVICE_INTEGRATION"
);
471
QString
targetKey
=
QString
::
fromLocal8Bit
(
integrationName
);
472
473
if
(
targetKey
.
isEmpty
()) {
474
return
;
475
}
476
477
QStringList
keys
=
QWaylandInputDeviceIntegrationFactory
::
keys
();
478
if
(
keys
.
contains
(
targetKey
)) {
479
mInputDeviceIntegration
.
reset
(
QWaylandInputDeviceIntegrationFactory
::
create
(
targetKey
,
QStringList
()));
480
qDebug
(
"Using the '%s' input device integration"
,
qPrintable
(
targetKey
));
481
}
else
{
482
qWarning
(
"Wayland inputdevice integration '%s' not found, using default"
,
qPrintable
(
targetKey
));
483
}
484
}
485
486
void
QWaylandIntegration
::
reconfigureInputContext
()
487
{
488
if
(!
mDisplay
) {
489
// This function can be called from QWaylandDisplay::registry_global() when we
490
// are in process of constructing QWaylandDisplay. Configuring input context
491
// in that case is done by calling reconfigureInputContext() from QWaylandIntegration
492
// constructor, after QWaylandDisplay has been constructed.
493
return
;
494
}
495
496
auto
requested
=
QPlatformInputContextFactory
::
requested
();
497
if
(
requested
.
contains
(
QLatin1String
(
"qtvirtualkeyboard"
)))
498
qCWarning
(
lcQpaWayland
) <<
"qtvirtualkeyboard currently is not supported at client-side,"
499
" use QT_IM_MODULES=qtvirtualkeyboard at compositor-side."
;
500
501
if
(
mDisplay
->
isWaylandInputContextRequested
()
502
&& !
requested
.
contains
(
QLatin1String
(
WAYLAND_IM_KEY
)))
503
requested
.
append
(
QLatin1String
(
WAYLAND_IM_KEY
));
504
505
const
QString
defaultInputContext
(
QStringLiteral
(
"compose"
));
506
if
(!
requested
.
contains
(
defaultInputContext
))
507
requested
.
append
(
defaultInputContext
);
508
509
for
(
const
QString
&
imKey
:
requested
) {
510
if
(
imKey
==
QLatin1String
(
WAYLAND_IM_KEY
)) {
511
Q_ASSERT
(
mDisplay
->
isWaylandInputContextRequested
());
512
if
(
mDisplay
->
textInputMethodManager
() !=
nullptr
)
513
mInputContext
.
reset
(
new
QWaylandInputMethodContext
(
mDisplay
.
get
()));
514
else
if
(
mDisplay
->
textInputManagerv1
() !=
nullptr
515
||
mDisplay
->
textInputManagerv2
() !=
nullptr
516
||
mDisplay
->
textInputManagerv3
() !=
nullptr
)
517
mInputContext
.
reset
(
new
QWaylandInputContext
(
mDisplay
.
get
()));
518
}
else
{
519
mInputContext
.
reset
(
QPlatformInputContextFactory
::
create
(
imKey
));
520
}
521
522
if
(
mInputContext
&&
mInputContext
->
isValid
())
523
break
;
524
}
525
526
#
if
QT_CONFIG
(
xkbcommon
)
527
QXkbCommon
::
setXkbContext
(
mInputContext
.
get
(),
mDisplay
->
xkbContext
());
528
if
(
QWaylandInputContext
*
waylandInput
=
qobject_cast
<
QWaylandInputContext
*>(
mInputContext
.
get
())) {
529
waylandInput
->
setXkbContext
(
mDisplay
->
xkbContext
());
530
}
531
#
endif
532
533
qCDebug
(
lcQpaWayland
) <<
"using input method:"
<< (
inputContext
() ?
inputContext
()->
metaObject
()->
className
() :
"<none>"
);
534
}
535
536
QWaylandShellIntegration
*
QWaylandIntegration
::
createShellIntegration
(
const
QString
&
integrationName
)
537
{
538
if
(
QWaylandShellIntegrationFactory
::
keys
().
contains
(
integrationName
)) {
539
return
QWaylandShellIntegrationFactory
::
create
(
integrationName
,
mDisplay
.
get
());
540
}
else
{
541
qCWarning
(
lcQpaWayland
) <<
"No shell integration named"
<<
integrationName
<<
"found"
;
542
return
nullptr
;
543
}
544
}
545
546
#
ifndef
QT_NO_SESSIONMANAGER
547
QPlatformSessionManager
*
QWaylandIntegration
::
createPlatformSessionManager
(
const
QString
&
id
,
const
QString
&
key
)
const
548
{
549
Q_UNUSED
(
key
);
550
return
new
QWaylandSessionManager
(
mDisplay
.
get
(),
id
);
551
}
552
#
endif
553
554
void
QWaylandIntegration
::
reset
()
555
{
556
mServerBufferIntegration
.
reset
();
557
mServerBufferIntegrationInitialized
=
false
;
558
559
mInputDeviceIntegration
.
reset
();
560
561
mClientBufferIntegration
.
reset
();
562
mClientBufferIntegrationInitialized
=
false
;
563
}
564
565
void
QWaylandIntegration
::
setApplicationBadge
(
qint64
number
)
566
{
567
mPlatformServices
->
setApplicationBadge
(
number
);
568
}
569
570
void
QWaylandIntegration
::
beep
()
const
571
{
572
if
(
auto
bell
=
mDisplay
->
systemBell
()) {
573
bell
->
ring
(
nullptr
);
574
}
575
}
576
577
}
578
579
QT_END_NAMESPACE
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qrandomaccessasyncfile_darwin.mm:17
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