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>
This commit is contained in:
parent
0badceeb6d
commit
cb71234bc9
@ -444,7 +444,7 @@ void QWaylandXdgSurface::setPopup(QWaylandWindow *parent)
|
|||||||
{
|
{
|
||||||
Q_ASSERT(!m_toplevel && !m_popup);
|
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
|
// set_popup expects a position relative to the parent
|
||||||
QRect windowGeometry = m_window->windowContentGeometry();
|
QRect windowGeometry = m_window->windowContentGeometry();
|
||||||
QMargins windowMargins = m_window->windowContentMargins() - m_window->clientSideMargins();
|
QMargins windowMargins = m_window->windowContentMargins() - m_window->clientSideMargins();
|
||||||
@ -615,9 +615,8 @@ QString QWaylandXdgSurface::externWindowHandle()
|
|||||||
return m_toplevel->m_exported->handle();
|
return m_toplevel->m_exported->handle();
|
||||||
}
|
}
|
||||||
|
|
||||||
QWaylandXdgShell::QWaylandXdgShell(QWaylandDisplay *display, uint32_t id, uint32_t availableVersion)
|
QWaylandXdgShell::QWaylandXdgShell(QWaylandDisplay *display, QtWayland::xdg_wm_base *xdgWmBase)
|
||||||
: QtWayland::xdg_wm_base(display->wl_registry(), id, qMin(availableVersion, 4u))
|
: m_display(display), m_xdgWmBase(xdgWmBase)
|
||||||
, m_display(display)
|
|
||||||
{
|
{
|
||||||
display->addRegistryListener(&QWaylandXdgShell::handleRegistryGlobal, this);
|
display->addRegistryListener(&QWaylandXdgShell::handleRegistryGlobal, this);
|
||||||
}
|
}
|
||||||
@ -625,17 +624,6 @@ QWaylandXdgShell::QWaylandXdgShell(QWaylandDisplay *display, uint32_t id, uint32
|
|||||||
QWaylandXdgShell::~QWaylandXdgShell()
|
QWaylandXdgShell::~QWaylandXdgShell()
|
||||||
{
|
{
|
||||||
m_display->removeListener(&QWaylandXdgShell::handleRegistryGlobal, this);
|
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,
|
void QWaylandXdgShell::handleRegistryGlobal(void *data, wl_registry *registry, uint id,
|
||||||
|
@ -143,11 +143,11 @@ private:
|
|||||||
friend class QWaylandXdgShell;
|
friend class QWaylandXdgShell;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Q_WAYLANDCLIENT_EXPORT QWaylandXdgShell : public QtWayland::xdg_wm_base
|
class Q_WAYLANDCLIENT_EXPORT QWaylandXdgShell
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QWaylandXdgShell(QWaylandDisplay *display, uint32_t id, uint32_t availableVersion);
|
QWaylandXdgShell(QWaylandDisplay *display, QtWayland::xdg_wm_base *xdg_wm_base);
|
||||||
~QWaylandXdgShell() override;
|
~QWaylandXdgShell();
|
||||||
|
|
||||||
QWaylandDisplay *display() const { return m_display; }
|
QWaylandDisplay *display() const { return m_display; }
|
||||||
|
|
||||||
@ -156,14 +156,12 @@ public:
|
|||||||
QWaylandXdgExporterV2 *exporter() const { return m_xdgExporter.data(); }
|
QWaylandXdgExporterV2 *exporter() const { return m_xdgExporter.data(); }
|
||||||
QWaylandXdgSurface *getXdgSurface(QWaylandWindow *window);
|
QWaylandXdgSurface *getXdgSurface(QWaylandWindow *window);
|
||||||
|
|
||||||
protected:
|
|
||||||
void xdg_wm_base_ping(uint32_t serial) override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void handleRegistryGlobal(void *data, ::wl_registry *registry, uint id,
|
static void handleRegistryGlobal(void *data, ::wl_registry *registry, uint id,
|
||||||
const QString &interface, uint version);
|
const QString &interface, uint version);
|
||||||
|
|
||||||
QWaylandDisplay *m_display = nullptr;
|
QWaylandDisplay *m_display = nullptr;
|
||||||
|
QtWayland::xdg_wm_base *m_xdgWmBase = nullptr;
|
||||||
QScopedPointer<QWaylandXdgDecorationManagerV1> m_xdgDecorationManager;
|
QScopedPointer<QWaylandXdgDecorationManagerV1> m_xdgDecorationManager;
|
||||||
QScopedPointer<QWaylandXdgActivationV1> m_xdgActivation;
|
QScopedPointer<QWaylandXdgActivationV1> m_xdgActivation;
|
||||||
QScopedPointer<QWaylandXdgExporterV2> m_xdgExporter;
|
QScopedPointer<QWaylandXdgExporterV2> m_xdgExporter;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (C) 2017 The Qt Company Ltd.
|
// 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
|
// 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 "qwaylandxdgshellintegration_p.h"
|
||||||
#include "qwaylandxdgdecorationv1_p.h"
|
#include "qwaylandxdgdecorationv1_p.h"
|
||||||
|
|
||||||
@ -11,26 +12,38 @@ QT_BEGIN_NAMESPACE
|
|||||||
|
|
||||||
namespace QtWaylandClient {
|
namespace QtWaylandClient {
|
||||||
|
|
||||||
|
QWaylandXdgShellIntegration::QWaylandXdgShellIntegration() : QWaylandShellIntegrationTemplate(4)
|
||||||
|
{
|
||||||
|
connect(this, &QWaylandShellIntegrationTemplate::activeChanged, this, [this] {
|
||||||
|
if (isActive()) {
|
||||||
|
mXdgShell.reset(new QWaylandXdgShell(mDisplay, this));
|
||||||
|
} else {
|
||||||
|
mXdgShell.reset(nullptr);
|
||||||
|
destroy();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
QWaylandXdgShellIntegration::~QWaylandXdgShellIntegration()
|
||||||
|
{
|
||||||
|
if (isActive())
|
||||||
|
destroy();
|
||||||
|
}
|
||||||
|
|
||||||
bool QWaylandXdgShellIntegration::initialize(QWaylandDisplay *display)
|
bool QWaylandXdgShellIntegration::initialize(QWaylandDisplay *display)
|
||||||
{
|
{
|
||||||
for (QWaylandDisplay::RegistryGlobal global : display->globals()) {
|
mDisplay = display;
|
||||||
if (global.interface == QLatin1String("xdg_wm_base")) {
|
return QWaylandShellIntegrationTemplate::initialize(display);
|
||||||
m_xdgShell.reset(new QWaylandXdgShell(display, global.id, global.version));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_xdgShell) {
|
void QWaylandXdgShellIntegration::xdg_wm_base_ping(uint32_t serial)
|
||||||
qCDebug(lcQpaWayland) << "Couldn't find global xdg_wm_base for xdg-shell stable";
|
{
|
||||||
return false;
|
pong(serial);
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QWaylandShellSurface *QWaylandXdgShellIntegration::createShellSurface(QWaylandWindow *window)
|
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)
|
void *QWaylandXdgShellIntegration::nativeResourceForWindow(const QByteArray &resource, QWindow *window)
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
// We mean it.
|
// We mean it.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "qwaylandxdgshell_p.h"
|
#include "qwayland-xdg-shell.h"
|
||||||
|
|
||||||
#include <QtWaylandClient/private/qwaylandshellintegration_p.h>
|
#include <QtWaylandClient/private/qwaylandshellintegration_p.h>
|
||||||
|
|
||||||
@ -23,16 +23,25 @@ QT_BEGIN_NAMESPACE
|
|||||||
|
|
||||||
namespace QtWaylandClient {
|
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:
|
public:
|
||||||
QWaylandXdgShellIntegration() {}
|
QWaylandXdgShellIntegration();
|
||||||
bool initialize(QWaylandDisplay *display) override;
|
~QWaylandXdgShellIntegration() override;
|
||||||
QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
|
QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
|
||||||
void *nativeResourceForWindow(const QByteArray &resource, QWindow *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:
|
private:
|
||||||
QScopedPointer<QWaylandXdgShell> m_xdgShell;
|
QWaylandDisplay *mDisplay;
|
||||||
|
QScopedPointer<QWaylandXdgShell> mXdgShell;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user