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
6
14#if QT_CONFIG(clipboard)
15#include "qwaylandclipboard_p.h"
16#endif
17#include "qwaylanddnd_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
49
53
56
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
78
79using namespace Qt::StringLiterals;
80
81namespace QtWaylandClient {
82
84
104
109
111{
112 return mDisplay->initialize();
113}
114
119
121{
122 switch (cap) {
123 case ThreadedPixmaps: return true;
124 case OpenGL:
126 case ThreadedOpenGL:
129 return true;
130 case MultipleWindows:
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:
141 default: return QPlatformIntegration::hasCapability(cap);
142 }
143}
144
146{
150
151#if QT_CONFIG(vulkan)
154#endif // QT_CONFIG(vulkan)
155
156 return new QWaylandShmWindow(window, mDisplay.get());
157}
158
159#if QT_CONFIG(opengl) && QT_CONFIG(egl)
161{
164 return nullptr;
165}
166
168{
171 return nullptr;
172}
173
175{
177}
178#endif // opengl
179
184
189
194
195// Support platform specific initialization
197{
199
202#if QT_CONFIG(clipboard)
204#endif
205#if QT_CONFIG(draganddrop)
207#endif
208
210}
211
213{
215
216 // Call this after initializing event thread for QWaylandDisplay::flushRequests()
220
221 // Qt does not support running with no screens
223}
224
229
230#if QT_CONFIG(clipboard)
232{
233 return mClipboard.get();
234}
235#endif
236
237#if QT_CONFIG(draganddrop)
239{
240 return mDrag.get();
241}
242#endif // draganddrop
243
248
256
257#if QT_CONFIG(accessibility)
259{
260 if (!mAccessibility) {
261#if QT_CONFIG(accessibility_atspi_bridge)
262 Q_ASSERT_X(QCoreApplication::eventDispatcher(), "QWaylandIntegration",
263 "Initializing accessibility without event-dispatcher!");
265#else
267#endif
268 }
269 return mAccessibility.get();
270}
271#endif
272
277
279{
280 return mDisplay.get();
281}
282
284{
285 if (auto *seat = mDisplay->currentInputDevice(); seat && seat->keyboardFocus()) {
286 return seat->modifiers();
287 }
288 return Qt::NoModifier;
289}
290
292{
293 if (auto *seat = mDisplay->currentInputDevice())
294 return seat->possibleKeys(event);
295 return {};
296}
297
302
307
312
317
318#if QT_CONFIG(vulkan)
320{
322}
323#endif // QT_CONFIG(vulkan)
324
325// May be called from non-GUI threads
336
344
352
353// May be called from non-GUI threads
355{
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()) {
368 && mDisplay->hardwareIntegration()->clientBufferIntegration() != QLatin1String("wayland-eglstream-controller")
370 && mDisplay->hardwareIntegration()->clientBufferIntegration() != QLatin1String("linux-dmabuf-unstable-v1")) {
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 {
381 qCDebug(lcQpaWayland) << "Available client buffer integrations:" << keys;
382
385
387 qCDebug(lcQpaWayland) << "Initializing client buffer integration" << targetKey;
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.
398}
399
401{
403
404 QString targetKey = QString::fromLocal8Bit(qgetenv("QT_WAYLAND_SERVER_BUFFER_INTEGRATION"));
405
408
409 if (targetKey.isEmpty()) {
410 qWarning("Failed to determine what server buffer integration to use");
411 return;
412 }
413
415 qCDebug(lcQpaWayland) << "Available server buffer integrations:" << keys;
416
419
421 qCDebug(lcQpaWayland) << "Initializing server buffer integration" << targetKey;
423 } else {
424 qCWarning(lcQpaWayland) << "Failed to load server buffer integration: " << targetKey;
425 qCWarning(lcQpaWayland) << "Available server buffer integrations:" << keys;
426 }
427}
428
430{
432
433 QByteArray integrationNames = qgetenv("QT_WAYLAND_SHELL_INTEGRATION");
435
437 if (!targetKeys.isEmpty()) {
439 } else {
440 preferredShells << QLatin1String("xdg-shell");
441 preferredShells << QLatin1String("wl-shell") << QLatin1String("ivi-shell");
442 preferredShells << QLatin1String("qt-shell");
443 }
444
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
459}
460
468
470{
471 QByteArray integrationName = qgetenv("QT_WAYLAND_INPUTDEVICE_INTEGRATION");
473
474 if (targetKey.isEmpty()) {
475 return;
476 }
477
479 if (keys.contains(targetKey)) {
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
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
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
505
509
510 for (const QString &imKey : requested) {
513 if (mDisplay->textInputMethodManager() != nullptr)
515 else if (mDisplay->textInputManagerv1() != nullptr
516 || mDisplay->textInputManagerv2() != nullptr
517 || mDisplay->textInputManagerv3() != nullptr)
519 } else {
521 }
522
524 break;
525 }
526
527#if QT_CONFIG(xkbcommon)
531 }
532#endif
533
534 qCDebug(lcQpaWayland) << "using input method:" << (inputContext() ? inputContext()->metaObject()->className() : "<none>");
535}
536
538{
541 } else {
542 qCWarning(lcQpaWayland) << "No shell integration named" << integrationName << "found";
543 return nullptr;
544 }
545}
546
547#ifndef QT_NO_SESSIONMANAGER
553#endif
554
565
570
572{
573 if (auto bell = mDisplay->systemBell()) {
574 bell->ring(nullptr);
575 }
576}
577
578}
579
580QT_END_NAMESPACE
Combined button and popup list for selecting options.
#define WAYLAND_IM_KEY