From 6caaf81f9b23600528e34f490651997360f03403 Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Tue, 22 Nov 2016 13:37:10 +0100 Subject: [PATCH] Deprecate QT_WAYLAND_USE_XDG_SHELL In favor of QT_WAYLAND_SHELL_INTEGRATION, which can be set to: - ivi-shell - wl-shell - xdg-shell-v5 - xdg-shell-v6 Change-Id: Ie2ca1184f22dcac56beb441329ea8b5a9a81baf4 Reviewed-by: Paul Olav Tvete --- .../platforms/wayland/qwaylandintegration.cpp | 50 ++++++++++--------- .../wayland/qwaylandwlshellintegration.cpp | 7 +++ .../wayland/qwaylandwlshellintegration_p.h | 4 +- .../wayland/qwaylandxdgshellintegration.cpp | 7 +++ .../wayland/qwaylandxdgshellintegration_p.h | 4 +- .../wayland/qwaylandxdgshellv6integration.cpp | 7 +++ .../wayland/qwaylandxdgshellv6integration_p.h | 4 +- 7 files changed, 56 insertions(+), 27 deletions(-) diff --git a/src/plugins/platforms/wayland/qwaylandintegration.cpp b/src/plugins/platforms/wayland/qwaylandintegration.cpp index 0dcd6b68f0c..f9ee611567d 100644 --- a/src/plugins/platforms/wayland/qwaylandintegration.cpp +++ b/src/plugins/platforms/wayland/qwaylandintegration.cpp @@ -375,25 +375,25 @@ void QWaylandIntegration::initializeShellIntegration() QByteArray integrationName = qgetenv("QT_WAYLAND_SHELL_INTEGRATION"); QString targetKey = QString::fromLocal8Bit(integrationName); + QStringList preferredShells; if (!targetKey.isEmpty()) { - QStringList keys = QWaylandShellIntegrationFactory::keys(); - if (keys.contains(targetKey)) { - qDebug("Using the '%s' shell integration", qPrintable(targetKey)); - mShellIntegration.reset(QWaylandShellIntegrationFactory::create(targetKey, QStringList())); - } + preferredShells << targetKey; } else { - QStringList preferredShells; - preferredShells << QLatin1String("zxdg_shell_v6"); - if (qEnvironmentVariableIsSet("QT_WAYLAND_USE_XDG_SHELL")) - preferredShells << QLatin1String("xdg_shell"); + preferredShells << QLatin1String("xdg-shell-v6"); + QString useXdgShell = QString::fromLocal8Bit(qgetenv("QT_WAYLAND_USE_XDG_SHELL")); + if (!useXdgShell.isEmpty() && useXdgShell != QLatin1String("0")) { + qWarning() << "QT_WAYLAND_USE_XDG_SHELL is deprecated, " + "please specify the shell using QT_WAYLAND_SHELL_INTEGRATION instead"; + preferredShells << QLatin1String("xdg-shell-v5"); + } + preferredShells << QLatin1String("wl-shell"); + } - preferredShells << QLatin1String("wl_shell"); - - Q_FOREACH (QString preferredShell, preferredShells) { - if (mDisplay->hasRegistryGlobal(preferredShell)) { - mShellIntegration.reset(createShellIntegration(preferredShell)); - break; - } + Q_FOREACH (QString preferredShell, preferredShells) { + mShellIntegration.reset(createShellIntegration(preferredShell)); + if (mShellIntegration) { + qDebug("Using the '%s' shell integration", qPrintable(preferredShell)); + break; } } @@ -429,16 +429,18 @@ void QWaylandIntegration::initializeInputDeviceIntegration() } } -QWaylandShellIntegration *QWaylandIntegration::createShellIntegration(const QString &interfaceName) +QWaylandShellIntegration *QWaylandIntegration::createShellIntegration(const QString &integrationName) { - if (interfaceName == QLatin1Literal("wl_shell")) { - return new QWaylandWlShellIntegration(mDisplay.data()); - } else if (interfaceName == QLatin1Literal("xdg_shell")) { - return new QWaylandXdgShellIntegration(mDisplay.data()); - } else if (interfaceName == QLatin1Literal("zxdg_shell_v6")) { - return new QWaylandXdgShellV6Integration(mDisplay.data()); + if (integrationName == QLatin1Literal("wl-shell")) { + return QWaylandWlShellIntegration::create(mDisplay.data()); + } else if (integrationName == QLatin1Literal("xdg-shell-v5")) { + return QWaylandXdgShellIntegration::create(mDisplay.data()); + } else if (integrationName == QLatin1Literal("xdg-shell-v6")) { + return QWaylandXdgShellV6Integration::create(mDisplay.data()); + } else if (QWaylandShellIntegrationFactory::keys().contains(integrationName)) { + return QWaylandShellIntegrationFactory::create(integrationName, QStringList()); } else { - return Q_NULLPTR; + return nullptr; } } diff --git a/src/plugins/platforms/wayland/qwaylandwlshellintegration.cpp b/src/plugins/platforms/wayland/qwaylandwlshellintegration.cpp index ce7c7834617..8d61201bdd7 100644 --- a/src/plugins/platforms/wayland/qwaylandwlshellintegration.cpp +++ b/src/plugins/platforms/wayland/qwaylandwlshellintegration.cpp @@ -41,6 +41,13 @@ QT_BEGIN_NAMESPACE namespace QtWaylandClient { +QWaylandWlShellIntegration *QWaylandWlShellIntegration::create(QWaylandDisplay *display) +{ + if (display->hasRegistryGlobal(QLatin1String("wl_shell"))) + return new QWaylandWlShellIntegration(display); + return nullptr; +} + QWaylandWlShellIntegration::QWaylandWlShellIntegration(QWaylandDisplay *display) : m_wlShell(Q_NULLPTR) { diff --git a/src/plugins/platforms/wayland/qwaylandwlshellintegration_p.h b/src/plugins/platforms/wayland/qwaylandwlshellintegration_p.h index 9082c7628d1..393ccaf0ac2 100644 --- a/src/plugins/platforms/wayland/qwaylandwlshellintegration_p.h +++ b/src/plugins/platforms/wayland/qwaylandwlshellintegration_p.h @@ -57,11 +57,13 @@ namespace QtWaylandClient { class Q_WAYLAND_CLIENT_EXPORT QWaylandWlShellIntegration : public QWaylandShellIntegration { public: - QWaylandWlShellIntegration(QWaylandDisplay* display); + static QWaylandWlShellIntegration *create(QWaylandDisplay* display); bool initialize(QWaylandDisplay *) Q_DECL_OVERRIDE; QWaylandShellSurface *createShellSurface(QWaylandWindow *window) Q_DECL_OVERRIDE; private: + QWaylandWlShellIntegration(QWaylandDisplay* display); + QtWayland::wl_shell *m_wlShell; }; diff --git a/src/plugins/platforms/wayland/qwaylandxdgshellintegration.cpp b/src/plugins/platforms/wayland/qwaylandxdgshellintegration.cpp index a48157dfac9..439dd4b1539 100644 --- a/src/plugins/platforms/wayland/qwaylandxdgshellintegration.cpp +++ b/src/plugins/platforms/wayland/qwaylandxdgshellintegration.cpp @@ -43,6 +43,13 @@ QT_BEGIN_NAMESPACE namespace QtWaylandClient { +QWaylandXdgShellIntegration *QWaylandXdgShellIntegration::create(QWaylandDisplay *display) +{ + if (display->hasRegistryGlobal(QLatin1String("xdg_shell"))) + return new QWaylandXdgShellIntegration(display); + return nullptr; +} + QWaylandXdgShellIntegration::QWaylandXdgShellIntegration(QWaylandDisplay *display) : m_xdgShell(Q_NULLPTR) { diff --git a/src/plugins/platforms/wayland/qwaylandxdgshellintegration_p.h b/src/plugins/platforms/wayland/qwaylandxdgshellintegration_p.h index e0e6bda0dc5..0658e52b755 100644 --- a/src/plugins/platforms/wayland/qwaylandxdgshellintegration_p.h +++ b/src/plugins/platforms/wayland/qwaylandxdgshellintegration_p.h @@ -58,12 +58,14 @@ class QWaylandXdgShell; class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgShellIntegration : public QWaylandShellIntegration { public: - QWaylandXdgShellIntegration(QWaylandDisplay *display); + static QWaylandXdgShellIntegration *create(QWaylandDisplay* display); bool initialize(QWaylandDisplay *display) Q_DECL_OVERRIDE; QWaylandShellSurface *createShellSurface(QWaylandWindow *window) Q_DECL_OVERRIDE; void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) Q_DECL_OVERRIDE; private: + QWaylandXdgShellIntegration(QWaylandDisplay *display); + QWaylandXdgShell *m_xdgShell; }; diff --git a/src/plugins/platforms/wayland/qwaylandxdgshellv6integration.cpp b/src/plugins/platforms/wayland/qwaylandxdgshellv6integration.cpp index 93f31987590..26f50c376b6 100644 --- a/src/plugins/platforms/wayland/qwaylandxdgshellv6integration.cpp +++ b/src/plugins/platforms/wayland/qwaylandxdgshellv6integration.cpp @@ -55,6 +55,13 @@ QWaylandXdgShellV6Integration::QWaylandXdgShellV6Integration(QWaylandDisplay *di } } +QWaylandXdgShellV6Integration *QWaylandXdgShellV6Integration::create(QWaylandDisplay *display) +{ + if (display->hasRegistryGlobal(QLatin1String("zxdg_shell_v6"))) + return new QWaylandXdgShellV6Integration(display); + return nullptr; +} + bool QWaylandXdgShellV6Integration::initialize(QWaylandDisplay *display) { QWaylandShellIntegration::initialize(display); diff --git a/src/plugins/platforms/wayland/qwaylandxdgshellv6integration_p.h b/src/plugins/platforms/wayland/qwaylandxdgshellv6integration_p.h index 2e9cdac4fb1..21868c4111d 100644 --- a/src/plugins/platforms/wayland/qwaylandxdgshellv6integration_p.h +++ b/src/plugins/platforms/wayland/qwaylandxdgshellv6integration_p.h @@ -58,11 +58,13 @@ class QWaylandXdgShellV6; class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgShellV6Integration : public QWaylandShellIntegration { public: - QWaylandXdgShellV6Integration(QWaylandDisplay *display); + static QWaylandXdgShellV6Integration *create(QWaylandDisplay* display); bool initialize(QWaylandDisplay *display) override; QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override; private: + QWaylandXdgShellV6Integration(QWaylandDisplay *display); + QWaylandXdgShellV6 *m_xdgShell; };