summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Olav Tvete <paul.tvete@qt.io>2021-12-02 09:59:09 +0100
committerPaul Olav Tvete <paul.tvete@qt.io>2021-12-09 13:57:23 +0100
commitf13fd0b32c94b8b35c3d7bd702552e012a7e526e (patch)
tree7eee0d4be55c48a8cc16bf478241ba8b062c00ee
parent39e3290efa2dd40722fa3322284cae3b01ccedf4 (diff)
Remove QWaylandShellIntegration::findGlobal
This is no longer necessary now that the recommended way of creating custom shells is to use QWaylandShellIntegrationTemplate. This also restores the old internal API in use by existing shells. Task-number: QTBUG-94330 Change-Id: I0fa0ba0d928baa2edf5d68e879558081026436c8 Reviewed-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> Reviewed-by: David Edmundson <davidedmundson@kde.org>
-rw-r--r--src/client/shellintegration/qwaylandshellintegration.cpp13
-rw-r--r--src/client/shellintegration/qwaylandshellintegration_p.h13
-rw-r--r--src/plugins/shellintegration/fullscreen-shell-v1/qwaylandfullscreenshellv1integration.cpp19
-rw-r--r--src/plugins/shellintegration/fullscreen-shell-v1/qwaylandfullscreenshellv1integration.h3
-rw-r--r--src/plugins/shellintegration/ivi-shell/qwaylandivishellintegration.cpp23
-rw-r--r--src/plugins/shellintegration/ivi-shell/qwaylandivishellintegration.h3
-rw-r--r--src/plugins/shellintegration/qt-shell/qwaylandqtshellintegration.cpp22
-rw-r--r--src/plugins/shellintegration/qt-shell/qwaylandqtshellintegration.h9
-rw-r--r--src/plugins/shellintegration/wl-shell/qwaylandwlshellintegration.cpp17
-rw-r--r--src/plugins/shellintegration/wl-shell/qwaylandwlshellintegration_p.h2
-rw-r--r--src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp18
-rw-r--r--src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h2
12 files changed, 46 insertions, 98 deletions
diff --git a/src/client/shellintegration/qwaylandshellintegration.cpp b/src/client/shellintegration/qwaylandshellintegration.cpp
index 7bc37792f..5bb617034 100644
--- a/src/client/shellintegration/qwaylandshellintegration.cpp
+++ b/src/client/shellintegration/qwaylandshellintegration.cpp
@@ -39,19 +39,6 @@ wl_surface *QWaylandShellIntegration::wlSurfaceForWindow(QWaylandWindow *window)
return window->wlSurface();
}
-bool QWaylandShellIntegration::findGlobal(const QString &interface, wl_registry **registry, uint32_t *id, uint32_t *version)
-{
- for (QWaylandDisplay::RegistryGlobal &global : m_display->globals()) {
- if (global.interface == interface) {
- *registry = m_display->wl_registry();
- *id = global.id;
- *version = global.version;
- return true;
- }
- }
- return false;
-}
-
}
QT_END_NAMESPACE
diff --git a/src/client/shellintegration/qwaylandshellintegration_p.h b/src/client/shellintegration/qwaylandshellintegration_p.h
index 4de19e786..8acbf9670 100644
--- a/src/client/shellintegration/qwaylandshellintegration_p.h
+++ b/src/client/shellintegration/qwaylandshellintegration_p.h
@@ -77,13 +77,7 @@ public:
QWaylandShellIntegration() {}
virtual ~QWaylandShellIntegration() {}
- bool initialize(QWaylandDisplay *display) {
- m_display = display;
- return initialize();
- }
- virtual bool initialize() {
- return false;
- }
+ virtual bool initialize(QWaylandDisplay *display) = 0;
virtual QWaylandShellSurface *createShellSurface(QWaylandWindow *window) = 0;
virtual void *nativeResourceForWindow(const QByteArray &resource, QWindow *window) {
Q_UNUSED(resource);
@@ -92,10 +86,7 @@ public:
}
static wl_surface *wlSurfaceForWindow(QWaylandWindow *window);
- bool findGlobal(const QString &interface, wl_registry **registry, uint32_t *id, uint32_t *version);
-protected:
- QWaylandDisplay *m_display = nullptr;
};
template <typename T>
@@ -107,7 +98,7 @@ public:
{
}
- bool initialize() override
+ bool initialize(QWaylandDisplay *) override
{
QWaylandClientExtension::initialize();
return isActive();
diff --git a/src/plugins/shellintegration/fullscreen-shell-v1/qwaylandfullscreenshellv1integration.cpp b/src/plugins/shellintegration/fullscreen-shell-v1/qwaylandfullscreenshellv1integration.cpp
index 033cbf6ec..418c7d3b3 100644
--- a/src/plugins/shellintegration/fullscreen-shell-v1/qwaylandfullscreenshellv1integration.cpp
+++ b/src/plugins/shellintegration/fullscreen-shell-v1/qwaylandfullscreenshellv1integration.cpp
@@ -44,22 +44,23 @@ QT_BEGIN_NAMESPACE
namespace QtWaylandClient {
-bool QWaylandFullScreenShellV1Integration::initialize()
+bool QWaylandFullScreenShellV1Integration::initialize(QWaylandDisplay *display)
{
- if (m_shell)
- return true;
- wl_registry *registry;
- uint32_t id;
- uint32_t version;
- bool found = findGlobal(QLatin1String("zwp_fullscreen_shell_v1"), &registry, &id, &version);
- if (found)
- m_shell.reset(new QtWayland::zwp_fullscreen_shell_v1(registry, id, version));
+ for (const QWaylandDisplay::RegistryGlobal &global : display->globals()) {
+ if (global.interface == QLatin1String("zwp_fullscreen_shell_v1") && !m_shell) {
+ m_shell.reset(new QtWayland::zwp_fullscreen_shell_v1(display->wl_registry(), global.id, global.version));
+ break;
+ }
+ }
+
if (!m_shell) {
qCDebug(lcQpaWayland) << "Couldn't find global zwp_fullscreen_shell_v1 for fullscreen-shell";
return false;
}
+
return true;
}
+
QWaylandShellSurface *QWaylandFullScreenShellV1Integration::createShellSurface(QWaylandWindow *window)
{
return new QWaylandFullScreenShellV1Surface(m_shell.data(), window);
diff --git a/src/plugins/shellintegration/fullscreen-shell-v1/qwaylandfullscreenshellv1integration.h b/src/plugins/shellintegration/fullscreen-shell-v1/qwaylandfullscreenshellv1integration.h
index da99f6c4e..131f9e720 100644
--- a/src/plugins/shellintegration/fullscreen-shell-v1/qwaylandfullscreenshellv1integration.h
+++ b/src/plugins/shellintegration/fullscreen-shell-v1/qwaylandfullscreenshellv1integration.h
@@ -43,7 +43,6 @@
#include <wayland-client.h>
#include <QtWaylandClient/private/qwayland-wayland.h>
#include <QtWaylandClient/private/qwaylandshellintegration_p.h>
-#include <QScopedPointer>
#include "qwayland-fullscreen-shell-unstable-v1.h"
@@ -54,7 +53,7 @@ namespace QtWaylandClient {
class Q_WAYLAND_CLIENT_EXPORT QWaylandFullScreenShellV1Integration : public QWaylandShellIntegration
{
public:
- bool initialize() override;
+ bool initialize(QWaylandDisplay *display) override;
QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
private:
diff --git a/src/plugins/shellintegration/ivi-shell/qwaylandivishellintegration.cpp b/src/plugins/shellintegration/ivi-shell/qwaylandivishellintegration.cpp
index aab5c573d..9c2af783d 100644
--- a/src/plugins/shellintegration/ivi-shell/qwaylandivishellintegration.cpp
+++ b/src/plugins/shellintegration/ivi-shell/qwaylandivishellintegration.cpp
@@ -60,29 +60,20 @@ QWaylandIviShellIntegration::QWaylandIviShellIntegration()
{
}
-bool QWaylandIviShellIntegration::initialize()
+bool QWaylandIviShellIntegration::initialize(QWaylandDisplay *display)
{
- if (!m_iviApplication) {
- wl_registry *registry;
- uint32_t id;
- uint32_t version;
- bool found = findGlobal(QLatin1String("ivi_application"), &registry, &id, &version);
- if (found)
- m_iviApplication.reset(new QtWayland::ivi_application(registry, id, version));
- }
- if (!m_iviController) {
- wl_registry *registry;
- uint32_t id;
- uint32_t version;
- bool found = findGlobal(QLatin1String("ivi_controller"), &registry, &id, &version);
- if (found)
- m_iviController.reset(new QtWayland::ivi_controller(registry, id, version));
+ for (QWaylandDisplay::RegistryGlobal global : display->globals()) {
+ if (global.interface == QLatin1String("ivi_application") && !m_iviApplication)
+ m_iviApplication.reset(new QtWayland::ivi_application(display->wl_registry(), global.id, global.version));
+ if (global.interface == QLatin1String("ivi_controller") && !m_iviController)
+ m_iviController.reset(new QtWayland::ivi_controller(display->wl_registry(), global.id, global.version));
}
if (!m_iviApplication) {
qCDebug(lcQpaWayland) << "Couldn't find global ivi_application for ivi-shell";
return false;
}
+
return true;
}
diff --git a/src/plugins/shellintegration/ivi-shell/qwaylandivishellintegration.h b/src/plugins/shellintegration/ivi-shell/qwaylandivishellintegration.h
index 40ec378cd..bf8c98775 100644
--- a/src/plugins/shellintegration/ivi-shell/qwaylandivishellintegration.h
+++ b/src/plugins/shellintegration/ivi-shell/qwaylandivishellintegration.h
@@ -45,7 +45,6 @@
#include <QtWaylandClient/private/qwaylandshellintegration_p.h>
#include "qwayland-ivi-application.h"
#include "qwayland-ivi-controller.h"
-#include <QScopedPointer>
QT_BEGIN_NAMESPACE
@@ -59,7 +58,7 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandIviShellIntegration : public QWaylandShell
public:
QWaylandIviShellIntegration();
- bool initialize() override;
+ bool initialize(QWaylandDisplay *display) override;
QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
private:
diff --git a/src/plugins/shellintegration/qt-shell/qwaylandqtshellintegration.cpp b/src/plugins/shellintegration/qt-shell/qwaylandqtshellintegration.cpp
index 225ee61f7..568599c66 100644
--- a/src/plugins/shellintegration/qt-shell/qwaylandqtshellintegration.cpp
+++ b/src/plugins/shellintegration/qt-shell/qwaylandqtshellintegration.cpp
@@ -56,31 +56,13 @@ QT_BEGIN_NAMESPACE
namespace QtWaylandClient {
QWaylandQtShellIntegration::QWaylandQtShellIntegration()
+ : QWaylandShellIntegrationTemplate(1)
{
}
-bool QWaylandQtShellIntegration::initialize()
-{
- if (m_qtShell)
- return true;
- wl_registry *registry;
- uint32_t id;
- uint32_t version;
- bool found = findGlobal(QLatin1String("zqt_shell_v1"), &registry, &id, &version);
- if (!found) {
- qCDebug(lcQpaWayland) << "Couldn't find global zqt_shell_v1 for qt-shell";
- return false;
- }
- m_qtShell.reset(new QtWayland::zqt_shell_v1(registry, id, version));
- return true;
-}
-
QWaylandShellSurface *QWaylandQtShellIntegration::createShellSurface(QWaylandWindow *window)
{
- if (!m_qtShell)
- return nullptr;
-
- auto *surface = m_qtShell->surface_create(wlSurfaceForWindow(window));
+ auto *surface = surface_create(wlSurfaceForWindow(window));
return new QWaylandQtSurface(surface, window);
}
diff --git a/src/plugins/shellintegration/qt-shell/qwaylandqtshellintegration.h b/src/plugins/shellintegration/qt-shell/qwaylandqtshellintegration.h
index 4feb216ae..e654c242f 100644
--- a/src/plugins/shellintegration/qt-shell/qwaylandqtshellintegration.h
+++ b/src/plugins/shellintegration/qt-shell/qwaylandqtshellintegration.h
@@ -53,16 +53,15 @@ namespace QtWaylandClient {
class QWaylandWindow;
class QWaylandDisplay;
-class Q_WAYLAND_CLIENT_EXPORT QWaylandQtShellIntegration : public QWaylandShellIntegration
+
+class Q_WAYLAND_CLIENT_EXPORT QWaylandQtShellIntegration
+ : public QWaylandShellIntegrationTemplate<QWaylandQtShellIntegration>
+ , public QtWayland::zqt_shell_v1
{
public:
QWaylandQtShellIntegration();
- bool initialize() override;
QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
-
-private:
- QScopedPointer<QtWayland::zqt_shell_v1> m_qtShell;
};
}
diff --git a/src/plugins/shellintegration/wl-shell/qwaylandwlshellintegration.cpp b/src/plugins/shellintegration/wl-shell/qwaylandwlshellintegration.cpp
index 7353cb1f9..262410f39 100644
--- a/src/plugins/shellintegration/wl-shell/qwaylandwlshellintegration.cpp
+++ b/src/plugins/shellintegration/wl-shell/qwaylandwlshellintegration.cpp
@@ -47,16 +47,15 @@ QT_BEGIN_NAMESPACE
namespace QtWaylandClient {
-bool QWaylandWlShellIntegration::initialize()
+bool QWaylandWlShellIntegration::initialize(QWaylandDisplay *display)
{
- if (m_wlShell)
- return true;
- wl_registry *registry;
- uint32_t id;
- uint32_t version;
- bool found = findGlobal(QLatin1String("wl_shell"), &registry, &id, &version);
- if (found)
- m_wlShell = new QtWayland::wl_shell(registry, id, 1);
+ const auto globals = display->globals();
+ for (QWaylandDisplay::RegistryGlobal global : globals) {
+ if (global.interface == QLatin1String("wl_shell")) {
+ m_wlShell = new QtWayland::wl_shell(display->wl_registry(), global.id, 1);
+ break;
+ }
+ }
if (!m_wlShell) {
qCDebug(lcQpaWayland) << "Couldn't find global wl_shell";
diff --git a/src/plugins/shellintegration/wl-shell/qwaylandwlshellintegration_p.h b/src/plugins/shellintegration/wl-shell/qwaylandwlshellintegration_p.h
index 47815d54a..3d76cc310 100644
--- a/src/plugins/shellintegration/wl-shell/qwaylandwlshellintegration_p.h
+++ b/src/plugins/shellintegration/wl-shell/qwaylandwlshellintegration_p.h
@@ -63,7 +63,7 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandWlShellIntegration : public QWaylandShellI
{
public:
QWaylandWlShellIntegration() {}
- bool initialize() override;
+ bool initialize(QWaylandDisplay *) override;
QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
void *nativeResourceForWindow(const QByteArray &resource, QWindow *window) override;
diff --git a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
index 8390d76f6..0c9a2f2b2 100644
--- a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
+++ b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
@@ -47,20 +47,20 @@ QT_BEGIN_NAMESPACE
namespace QtWaylandClient {
-bool QWaylandXdgShellIntegration::initialize()
+bool QWaylandXdgShellIntegration::initialize(QWaylandDisplay *display)
{
- if (m_xdgShell)
- return true;
- wl_registry *registry;
- uint32_t id;
- uint32_t version;
- bool found = findGlobal(QLatin1String("xdg_wm_base"), &registry, &id, &version);
- if (found)
- m_xdgShell.reset(new QWaylandXdgShell(m_display, id, version));
+ for (QWaylandDisplay::RegistryGlobal global : display->globals()) {
+ if (global.interface == QLatin1String("xdg_wm_base")) {
+ m_xdgShell.reset(new QWaylandXdgShell(display, global.id, global.version));
+ break;
+ }
+ }
+
if (!m_xdgShell) {
qCDebug(lcQpaWayland) << "Couldn't find global xdg_wm_base for xdg-shell stable";
return false;
}
+
return true;
}
diff --git a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
index cd54dd489..fced9eb07 100644
--- a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
+++ b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
@@ -63,7 +63,7 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgShellIntegration : public QWaylandShell
{
public:
QWaylandXdgShellIntegration() {}
- bool initialize() override;
+ bool initialize(QWaylandDisplay *display) override;
QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
void *nativeResourceForWindow(const QByteArray &resource, QWindow *window) override;