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>
This commit is contained in:
Paul Olav Tvete 2021-12-02 09:59:09 +01:00
parent 18df960499
commit c31a609bbd
8 changed files with 32 additions and 55 deletions

View File

@ -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);

View File

@ -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:

View File

@ -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";

View File

@ -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;

View File

@ -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;
}

View File

@ -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;

View File

@ -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

View File

@ -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();