diff options
Diffstat (limited to 'src/client/qwaylandintegration.cpp')
-rw-r--r-- | src/client/qwaylandintegration.cpp | 43 |
1 files changed, 34 insertions, 9 deletions
diff --git a/src/client/qwaylandintegration.cpp b/src/client/qwaylandintegration.cpp index 749b8d403..bd59e4270 100644 --- a/src/client/qwaylandintegration.cpp +++ b/src/client/qwaylandintegration.cpp @@ -75,6 +75,8 @@ #include "qwaylandshellintegration_p.h" #include "qwaylandshellintegrationfactory_p.h" +#include "qwaylandxdgshellintegration_p.h" +#include "qwaylandwlshellintegration_p.h" #include "qwaylandinputdeviceintegration_p.h" #include "qwaylandinputdeviceintegrationfactory_p.h" @@ -377,17 +379,29 @@ void QWaylandIntegration::initializeShellIntegration() QByteArray integrationName = qgetenv("QT_WAYLAND_SHELL_INTEGRATION"); QString targetKey = QString::fromLocal8Bit(integrationName); - if (targetKey.isEmpty()) { - return; + if (!targetKey.isEmpty()) { + QStringList keys = QWaylandShellIntegrationFactory::keys(); + if (keys.contains(targetKey)) { + qDebug("Using the '%s' shell integration", qPrintable(targetKey)); + mShellIntegration = QWaylandShellIntegrationFactory::create(targetKey, QStringList()); + } + } else { + QStringList preferredShells; + if (qEnvironmentVariableIsSet("QT_WAYLAND_USE_XDG_SHELL")) + preferredShells << QLatin1String("xdg_shell"); + preferredShells << QLatin1String("wl_shell"); + + Q_FOREACH (QString preferredShell, preferredShells) { + if (mDisplay->hasRegistryGlobal(preferredShell)) { + mShellIntegration = createShellIntegration(preferredShell); + break; + } + } } - QStringList keys = QWaylandShellIntegrationFactory::keys(); - if (keys.contains(targetKey)) { - mShellIntegration = QWaylandShellIntegrationFactory::create(targetKey, QStringList()); - } - if (mShellIntegration && mShellIntegration->initialize(mDisplay)) { - qDebug("Using the '%s' shell integration", qPrintable(targetKey)); - } else { + Q_ASSERT(mShellIntegration); + + if (!mShellIntegration->initialize(mDisplay)) { delete mShellIntegration; mShellIntegration = Q_NULLPTR; qWarning("Failed to load shell integration %s", qPrintable(targetKey)); @@ -420,6 +434,17 @@ void QWaylandIntegration::initializeInputDeviceIntegration() } } +QWaylandShellIntegration *QWaylandIntegration::createShellIntegration(const QString &interfaceName) +{ + if (interfaceName == QLatin1Literal("wl_shell")) { + return new QWaylandWlShellIntegration(mDisplay); + } else if (interfaceName == QLatin1Literal("xdg_shell")) { + return new QWaylandXdgShellIntegration(mDisplay); + } else { + return Q_NULLPTR; + } +} + } QT_END_NAMESPACE |