diff options
author | Johan Klokkhammer Helsing <johan.helsing@qt.io> | 2016-08-05 10:10:58 +0200 |
---|---|---|
committer | Johan Helsing <johan.helsing@qt.io> | 2016-08-09 10:58:10 +0000 |
commit | b3b4778c237c43cfde02c4750017c37112c315c4 (patch) | |
tree | 9e9d8e01aa485386d2dd5b8a652ec0b17ca5d3ec /src/client/qwaylandintegration.cpp | |
parent | 1db3dee9432f28f35ec9c971444b8a889bbdd6e2 (diff) |
Make wl_shell and xdg_shell use the QWaylandShellIntegration interface
This simplifies the code in QWaylandDisplay and hopefully makes it easier to
implement a prioritized shell selection mechanism later.
Change-Id: I2bb3a13f8acedb60a6606cb3a8b5b228095eadf9
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
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 39fff533d..e62ef87f1 100644 --- a/src/client/qwaylandintegration.cpp +++ b/src/client/qwaylandintegration.cpp @@ -69,6 +69,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" @@ -360,17 +362,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)); @@ -403,6 +417,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 |