summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid Redondo <qt@david-redondo.de>2023-02-22 14:33:22 +0100
committerDavid Edmundson <davidedmundson@kde.org>2023-03-01 10:06:27 +0000
commitee92c05f34e96431e22b5735d3b864d08e2e4ad3 (patch)
treef22ccf70a8fb645b3e1ba4e7d2b5a600cc877e12 /src
parent801b217e06628b3bc8fc543798652c6267be549d (diff)
downloadqtwayland-ee92c05f34e96431e22b5735d3b864d08e2e4ad3.tar.gz
Port xdg shell plugin towards QWaylandShellIntegrationTemplate
Ports manual initialization to the automatic handling of the template. For now the integration QWaylandXdgShellIntegration and QWaylandXdgShell are still separate but could be merged in a future step. Change-Id: I73bb9674e62f24f403349784e1b1e52a39aa8e9f Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: David Edmundson <davidedmundson@kde.org>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp18
-rw-r--r--src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h10
-rw-r--r--src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp37
-rw-r--r--src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h19
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;
};
}