diff options
Diffstat (limited to 'src')
4 files changed, 46 insertions, 38 deletions
diff --git a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp index 6303fbc9..ee53341a 100644 --- a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp +++ b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp @@ -444,7 +444,7 @@ void QWaylandXdgSurface::setPopup(QWaylandWindow *parent) { Q_ASSERT(!m_toplevel && !m_popup); - auto positioner = new QtWayland::xdg_positioner(m_shell->create_positioner()); + auto positioner = new QtWayland::xdg_positioner(m_shell->m_xdgWmBase->create_positioner()); // set_popup expects a position relative to the parent QRect windowGeometry = m_window->windowContentGeometry(); QMargins windowMargins = m_window->windowContentMargins() - m_window->clientSideMargins(); @@ -615,9 +615,8 @@ QString QWaylandXdgSurface::externWindowHandle() return m_toplevel->m_exported->handle(); } -QWaylandXdgShell::QWaylandXdgShell(QWaylandDisplay *display, uint32_t id, uint32_t availableVersion) - : QtWayland::xdg_wm_base(display->wl_registry(), id, qMin(availableVersion, 4u)) - , m_display(display) +QWaylandXdgShell::QWaylandXdgShell(QWaylandDisplay *display, QtWayland::xdg_wm_base *xdgWmBase) + : m_display(display), m_xdgWmBase(xdgWmBase) { display->addRegistryListener(&QWaylandXdgShell::handleRegistryGlobal, this); } @@ -625,17 +624,6 @@ QWaylandXdgShell::QWaylandXdgShell(QWaylandDisplay *display, uint32_t id, uint32 QWaylandXdgShell::~QWaylandXdgShell() { m_display->removeListener(&QWaylandXdgShell::handleRegistryGlobal, this); - destroy(); -} - -QWaylandXdgSurface *QWaylandXdgShell::getXdgSurface(QWaylandWindow *window) -{ - return new QWaylandXdgSurface(this, get_xdg_surface(window->wlSurface()), window); -} - -void QWaylandXdgShell::xdg_wm_base_ping(uint32_t serial) -{ - pong(serial); } void QWaylandXdgShell::handleRegistryGlobal(void *data, wl_registry *registry, uint id, diff --git a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h index 58860269..bf51888e 100644 --- a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h +++ b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h @@ -143,11 +143,11 @@ private: friend class QWaylandXdgShell; }; -class Q_WAYLANDCLIENT_EXPORT QWaylandXdgShell : public QtWayland::xdg_wm_base +class Q_WAYLANDCLIENT_EXPORT QWaylandXdgShell { public: - QWaylandXdgShell(QWaylandDisplay *display, uint32_t id, uint32_t availableVersion); - ~QWaylandXdgShell() override; + QWaylandXdgShell(QWaylandDisplay *display, QtWayland::xdg_wm_base *xdg_wm_base); + ~QWaylandXdgShell(); QWaylandDisplay *display() const { return m_display; } @@ -156,14 +156,12 @@ public: QWaylandXdgExporterV2 *exporter() const { return m_xdgExporter.data(); } QWaylandXdgSurface *getXdgSurface(QWaylandWindow *window); -protected: - void xdg_wm_base_ping(uint32_t serial) override; - private: static void handleRegistryGlobal(void *data, ::wl_registry *registry, uint id, const QString &interface, uint version); QWaylandDisplay *m_display = nullptr; + QtWayland::xdg_wm_base *m_xdgWmBase = nullptr; QScopedPointer<QWaylandXdgDecorationManagerV1> m_xdgDecorationManager; QScopedPointer<QWaylandXdgActivationV1> m_xdgActivation; QScopedPointer<QWaylandXdgExporterV2> m_xdgExporter; diff --git a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp index 8d648b62..c7b757dd 100644 --- a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp +++ b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp @@ -1,6 +1,7 @@ // Copyright (C) 2017 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#include "qwaylandxdgshell_p.h" #include "qwaylandxdgshellintegration_p.h" #include "qwaylandxdgdecorationv1_p.h" @@ -11,26 +12,38 @@ QT_BEGIN_NAMESPACE namespace QtWaylandClient { -bool QWaylandXdgShellIntegration::initialize(QWaylandDisplay *display) +QWaylandXdgShellIntegration::QWaylandXdgShellIntegration() : QWaylandShellIntegrationTemplate(4) { - for (QWaylandDisplay::RegistryGlobal global : display->globals()) { - if (global.interface == QLatin1String("xdg_wm_base")) { - m_xdgShell.reset(new QWaylandXdgShell(display, global.id, global.version)); - break; + connect(this, &QWaylandShellIntegrationTemplate::activeChanged, this, [this] { + if (isActive()) { + mXdgShell.reset(new QWaylandXdgShell(mDisplay, this)); + } else { + mXdgShell.reset(nullptr); + destroy(); } - } + }); +} - if (!m_xdgShell) { - qCDebug(lcQpaWayland) << "Couldn't find global xdg_wm_base for xdg-shell stable"; - return false; - } +QWaylandXdgShellIntegration::~QWaylandXdgShellIntegration() +{ + if (isActive()) + destroy(); +} - return true; +bool QWaylandXdgShellIntegration::initialize(QWaylandDisplay *display) +{ + mDisplay = display; + return QWaylandShellIntegrationTemplate::initialize(display); +} + +void QWaylandXdgShellIntegration::xdg_wm_base_ping(uint32_t serial) +{ + pong(serial); } QWaylandShellSurface *QWaylandXdgShellIntegration::createShellSurface(QWaylandWindow *window) { - return m_xdgShell->getXdgSurface(window); + return new QWaylandXdgSurface(mXdgShell.get(), get_xdg_surface(window->wlSurface()), window); } void *QWaylandXdgShellIntegration::nativeResourceForWindow(const QByteArray &resource, QWindow *window) diff --git a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h index 2caa3a6e..b7627d80 100644 --- a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h +++ b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h @@ -15,7 +15,7 @@ // We mean it. // -#include "qwaylandxdgshell_p.h" +#include "qwayland-xdg-shell.h" #include <QtWaylandClient/private/qwaylandshellintegration_p.h> @@ -23,16 +23,25 @@ QT_BEGIN_NAMESPACE namespace QtWaylandClient { -class Q_WAYLANDCLIENT_EXPORT QWaylandXdgShellIntegration : public QWaylandShellIntegration +class QWaylandXdgShell; + +class Q_WAYLANDCLIENT_EXPORT QWaylandXdgShellIntegration + : public QWaylandShellIntegrationTemplate<QWaylandXdgShellIntegration>, + public QtWayland::xdg_wm_base { public: - QWaylandXdgShellIntegration() {} - bool initialize(QWaylandDisplay *display) override; + QWaylandXdgShellIntegration(); + ~QWaylandXdgShellIntegration() override; QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override; void *nativeResourceForWindow(const QByteArray &resource, QWindow *window) override; + bool initialize(QWaylandDisplay *display) override; + +protected: + void xdg_wm_base_ping(uint32_t serial) override; private: - QScopedPointer<QWaylandXdgShell> m_xdgShell; + QWaylandDisplay *mDisplay; + QScopedPointer<QWaylandXdgShell> mXdgShell; }; } |