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
.
data
()));
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
.
data
();
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
.
data
());
153
#
endif
// QT_CONFIG(vulkan)
154
155
return
new
QWaylandShmWindow
(
window
,
mDisplay
.
data
());
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
.
data
());
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
.
data
()));
203
#
endif
204
#
if
QT_CONFIG
(
draganddrop
)
205
mDrag
.
reset
(
new
QWaylandDrag
(
mDisplay
.
data
()));
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
.
data
(),
SLOT
(
flushRequests
()));
218
QObject
::
connect
(
dispatcher
,
SIGNAL
(
awake
()),
mDisplay
.
data
(),
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
.
data
();
227
}
228
229
#
if
QT_CONFIG
(
clipboard
)
230
QPlatformClipboard
*
QWaylandIntegration
::
clipboard
()
const
231
{
232
return
mClipboard
.
data
();
233
}
234
#
endif
235
236
#
if
QT_CONFIG
(
draganddrop
)
237
QPlatformDrag
*
QWaylandIntegration
::
drag
()
const
238
{
239
return
mDrag
.
data
();
240
}
241
#
endif
// draganddrop
242
243
QPlatformInputContext
*
QWaylandIntegration
::
inputContext
()
const
244
{
245
return
mInputContext
.
data
();
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
.
data
();
269
}
270
#
endif
271
272
QPlatformServices
*
QWaylandIntegration
::
services
()
const
273
{
274
return
mPlatformServices
.
data
();
275
}
276
277
QWaylandDisplay
*
QWaylandIntegration
::
display
()
const
278
{
279
return
mDisplay
.
data
();
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
return
mClientBufferIntegration
&&
mClientBufferIntegration
->
isValid
() ?
mClientBufferIntegration
.
data
() :
nullptr
;
333
}
334
335
QWaylandServerBufferIntegration
*
QWaylandIntegration
::
serverBufferIntegration
()
const
336
{
337
if
(!
mServerBufferIntegrationInitialized
)
338
const_cast
<
QWaylandIntegration
*>(
this
)->
initializeServerBufferIntegration
();
339
340
return
mServerBufferIntegration
.
data
();
341
}
342
343
QWaylandShellIntegration
*
QWaylandIntegration
::
shellIntegration
()
const
344
{
345
if
(!
mShellIntegrationInitialized
)
346
const_cast
<
QWaylandIntegration
*>(
this
)->
initializeShellIntegration
();
347
348
return
mShellIntegration
.
data
();
349
}
350
351
// May be called from non-GUI threads
352
void
QWaylandIntegration
::
initializeClientBufferIntegration
()
353
{
354
QMutexLocker
lock
(&
mClientBufferInitLock
);
355
if
(
mClientBufferIntegrationInitialized
)
356
return
;
357
358
QString
targetKey
=
QString
::
fromLocal8Bit
(
qgetenv
(
"QT_WAYLAND_CLIENT_BUFFER_INTEGRATION"
));
359
if
(
mPlatformName
==
"wayland-egl"_L1
)
360
targetKey
=
"wayland-egl"_L1
;
361
else
if
(
mPlatformName
==
"wayland-brcm"_L1
)
362
targetKey
=
"brcm"_L1
;
363
364
if
(
targetKey
.
isEmpty
()) {
365
if
(
mDisplay
->
hardwareIntegration
()
366
&&
mDisplay
->
hardwareIntegration
()->
clientBufferIntegration
() !=
QLatin1String
(
"wayland-eglstream-controller"
)
367
&&
mDisplay
->
hardwareIntegration
()->
clientBufferIntegration
() !=
QLatin1String
(
"linux-dmabuf-unstable-v1"
)) {
368
targetKey
=
mDisplay
->
hardwareIntegration
()->
clientBufferIntegration
();
369
}
else
{
370
targetKey
=
QLatin1String
(
"wayland-egl"
);
371
}
372
}
373
374
if
(
targetKey
.
isEmpty
()) {
375
qWarning
(
"Failed to determine what client buffer integration to use"
);
376
}
else
{
377
QStringList
keys
=
QWaylandClientBufferIntegrationFactory
::
keys
();
378
qCDebug
(
lcQpaWayland
) <<
"Available client buffer integrations:"
<<
keys
;
379
380
if
(
keys
.
contains
(
targetKey
))
381
mClientBufferIntegration
.
reset
(
QWaylandClientBufferIntegrationFactory
::
create
(
targetKey
,
QStringList
()));
382
383
if
(
mClientBufferIntegration
) {
384
qCDebug
(
lcQpaWayland
) <<
"Initializing client buffer integration"
<<
targetKey
;
385
mClientBufferIntegration
->
initialize
(
mDisplay
.
data
());
386
}
else
{
387
qCWarning
(
lcQpaWayland
) <<
"Failed to load client buffer integration:"
<<
targetKey
;
388
qCWarning
(
lcQpaWayland
) <<
"Available client buffer integrations:"
<<
keys
;
389
}
390
}
391
392
// This must be set last to make sure other threads don't use the
393
// integration before initialization is complete.
394
mClientBufferIntegrationInitialized
=
true
;
395
}
396
397
void
QWaylandIntegration
::
initializeServerBufferIntegration
()
398
{
399
mServerBufferIntegrationInitialized
=
true
;
400
401
QString
targetKey
=
QString
::
fromLocal8Bit
(
qgetenv
(
"QT_WAYLAND_SERVER_BUFFER_INTEGRATION"
));
402
403
if
(
targetKey
.
isEmpty
() &&
mDisplay
->
hardwareIntegration
())
404
targetKey
=
mDisplay
->
hardwareIntegration
()->
serverBufferIntegration
();
405
406
if
(
targetKey
.
isEmpty
()) {
407
qWarning
(
"Failed to determine what server buffer integration to use"
);
408
return
;
409
}
410
411
QStringList
keys
=
QWaylandServerBufferIntegrationFactory
::
keys
();
412
qCDebug
(
lcQpaWayland
) <<
"Available server buffer integrations:"
<<
keys
;
413
414
if
(
keys
.
contains
(
targetKey
))
415
mServerBufferIntegration
.
reset
(
QWaylandServerBufferIntegrationFactory
::
create
(
targetKey
,
QStringList
()));
416
417
if
(
mServerBufferIntegration
) {
418
qCDebug
(
lcQpaWayland
) <<
"Initializing server buffer integration"
<<
targetKey
;
419
mServerBufferIntegration
->
initialize
(
mDisplay
.
data
());
420
}
else
{
421
qCWarning
(
lcQpaWayland
) <<
"Failed to load server buffer integration: "
<<
targetKey
;
422
qCWarning
(
lcQpaWayland
) <<
"Available server buffer integrations:"
<<
keys
;
423
}
424
}
425
426
void
QWaylandIntegration
::
initializeShellIntegration
()
427
{
428
mShellIntegrationInitialized
=
true
;
429
430
QByteArray
integrationNames
=
qgetenv
(
"QT_WAYLAND_SHELL_INTEGRATION"
);
431
QString
targetKeys
=
QString
::
fromLocal8Bit
(
integrationNames
);
432
433
QStringList
preferredShells
;
434
if
(!
targetKeys
.
isEmpty
()) {
435
preferredShells
=
targetKeys
.
split
(
QLatin1Char
(
';'
));
436
}
else
{
437
preferredShells
<<
QLatin1String
(
"xdg-shell"
);
438
preferredShells
<<
QLatin1String
(
"wl-shell"
) <<
QLatin1String
(
"ivi-shell"
);
439
preferredShells
<<
QLatin1String
(
"qt-shell"
);
440
}
441
442
for
(
const
QString
&
preferredShell
:
std
::
as_const
(
preferredShells
)) {
443
mShellIntegration
.
reset
(
createShellIntegration
(
preferredShell
));
444
if
(
mShellIntegration
) {
445
qCDebug
(
lcQpaWayland
,
"Using the '%s' shell integration"
,
qPrintable
(
preferredShell
));
446
break
;
447
}
448
}
449
450
if
(!
mShellIntegration
) {
451
qCWarning
(
lcQpaWayland
) <<
"Loading shell integration failed."
;
452
qCWarning
(
lcQpaWayland
) <<
"Attempted to load the following shells"
<<
preferredShells
;
453
}
454
455
QWindowSystemInterfacePrivate
::
TabletEvent
::
setPlatformSynthesizesMouse
(
false
);
456
}
457
458
QWaylandInputDevice
*
QWaylandIntegration
::
createInputDevice
(
QWaylandDisplay
*
display
,
int
version
,
uint32_t
id
)
const
459
{
460
if
(
mInputDeviceIntegration
) {
461
return
mInputDeviceIntegration
->
createInputDevice
(
display
,
version
,
id
);
462
}
463
return
new
QWaylandInputDevice
(
display
,
version
,
id
);
464
}
465
466
void
QWaylandIntegration
::
initializeInputDeviceIntegration
()
467
{
468
QByteArray
integrationName
=
qgetenv
(
"QT_WAYLAND_INPUTDEVICE_INTEGRATION"
);
469
QString
targetKey
=
QString
::
fromLocal8Bit
(
integrationName
);
470
471
if
(
targetKey
.
isEmpty
()) {
472
return
;
473
}
474
475
QStringList
keys
=
QWaylandInputDeviceIntegrationFactory
::
keys
();
476
if
(
keys
.
contains
(
targetKey
)) {
477
mInputDeviceIntegration
.
reset
(
QWaylandInputDeviceIntegrationFactory
::
create
(
targetKey
,
QStringList
()));
478
qDebug
(
"Using the '%s' input device integration"
,
qPrintable
(
targetKey
));
479
}
else
{
480
qWarning
(
"Wayland inputdevice integration '%s' not found, using default"
,
qPrintable
(
targetKey
));
481
}
482
}
483
484
void
QWaylandIntegration
::
reconfigureInputContext
()
485
{
486
if
(!
mDisplay
) {
487
// This function can be called from QWaylandDisplay::registry_global() when we
488
// are in process of constructing QWaylandDisplay. Configuring input context
489
// in that case is done by calling reconfigureInputContext() from QWaylandIntegration
490
// constructor, after QWaylandDisplay has been constructed.
491
return
;
492
}
493
494
auto
requested
=
QPlatformInputContextFactory
::
requested
();
495
if
(
requested
.
contains
(
QLatin1String
(
"qtvirtualkeyboard"
)))
496
qCWarning
(
lcQpaWayland
) <<
"qtvirtualkeyboard currently is not supported at client-side,"
497
" use QT_IM_MODULES=qtvirtualkeyboard at compositor-side."
;
498
499
if
(
mDisplay
->
isWaylandInputContextRequested
()
500
&& !
requested
.
contains
(
QLatin1String
(
WAYLAND_IM_KEY
)))
501
requested
.
append
(
QLatin1String
(
WAYLAND_IM_KEY
));
502
503
const
QString
defaultInputContext
(
QStringLiteral
(
"compose"
));
504
if
(!
requested
.
contains
(
defaultInputContext
))
505
requested
.
append
(
defaultInputContext
);
506
507
for
(
const
QString
&
imKey
:
requested
) {
508
if
(
imKey
==
QLatin1String
(
WAYLAND_IM_KEY
)) {
509
Q_ASSERT
(
mDisplay
->
isWaylandInputContextRequested
());
510
if
(
mDisplay
->
textInputMethodManager
() !=
nullptr
)
511
mInputContext
.
reset
(
new
QWaylandInputMethodContext
(
mDisplay
.
data
()));
512
else
if
(
mDisplay
->
textInputManagerv1
() !=
nullptr
513
||
mDisplay
->
textInputManagerv2
() !=
nullptr
514
||
mDisplay
->
textInputManagerv3
() !=
nullptr
)
515
mInputContext
.
reset
(
new
QWaylandInputContext
(
mDisplay
.
data
()));
516
}
else
{
517
mInputContext
.
reset
(
QPlatformInputContextFactory
::
create
(
imKey
));
518
}
519
520
if
(
mInputContext
&&
mInputContext
->
isValid
())
521
break
;
522
}
523
524
#
if
QT_CONFIG
(
xkbcommon
)
525
QXkbCommon
::
setXkbContext
(
mInputContext
.
data
(),
mDisplay
->
xkbContext
());
526
if
(
QWaylandInputContext
*
waylandInput
=
qobject_cast
<
QWaylandInputContext
*>(
mInputContext
.
get
())) {
527
waylandInput
->
setXkbContext
(
mDisplay
->
xkbContext
());
528
}
529
#
endif
530
531
qCDebug
(
lcQpaWayland
) <<
"using input method:"
<< (
inputContext
() ?
inputContext
()->
metaObject
()->
className
() :
"<none>"
);
532
}
533
534
QWaylandShellIntegration
*
QWaylandIntegration
::
createShellIntegration
(
const
QString
&
integrationName
)
535
{
536
if
(
QWaylandShellIntegrationFactory
::
keys
().
contains
(
integrationName
)) {
537
return
QWaylandShellIntegrationFactory
::
create
(
integrationName
,
mDisplay
.
data
());
538
}
else
{
539
qCWarning
(
lcQpaWayland
) <<
"No shell integration named"
<<
integrationName
<<
"found"
;
540
return
nullptr
;
541
}
542
}
543
544
#
ifndef
QT_NO_SESSIONMANAGER
545
QPlatformSessionManager
*
QWaylandIntegration
::
createPlatformSessionManager
(
const
QString
&
id
,
const
QString
&
key
)
const
546
{
547
Q_UNUSED
(
key
);
548
return
new
QWaylandSessionManager
(
mDisplay
.
data
(),
id
);
549
}
550
#
endif
551
552
void
QWaylandIntegration
::
reset
()
553
{
554
mServerBufferIntegration
.
reset
();
555
mServerBufferIntegrationInitialized
=
false
;
556
557
mInputDeviceIntegration
.
reset
();
558
559
mClientBufferIntegration
.
reset
();
560
mClientBufferIntegrationInitialized
=
false
;
561
}
562
563
void
QWaylandIntegration
::
setApplicationBadge
(
qint64
number
)
564
{
565
mPlatformServices
->
setApplicationBadge
(
number
);
566
}
567
568
void
QWaylandIntegration
::
beep
()
const
569
{
570
if
(
auto
bell
=
mDisplay
->
systemBell
()) {
571
bell
->
ring
(
nullptr
);
572
}
573
}
574
575
}
576
577
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:45
qtbase
src
plugins
platforms
wayland
qwaylandintegration.cpp
Generated on
for Qt by
1.16.1