diff --git a/plugins/platforms/wayland/wayland_backend.cpp b/plugins/platforms/wayland/wayland_backend.cpp
index c70bd00cbb..918ee410d3 100644
--- a/plugins/platforms/wayland/wayland_backend.cpp
+++ b/plugins/platforms/wayland/wayland_backend.cpp
@@ -45,6 +45,7 @@ along with this program. If not, see .
#include
#include
#include
+#include
#include
#include
#include
@@ -281,12 +282,18 @@ WaylandBackend::WaylandBackend(QObject *parent)
WaylandBackend::~WaylandBackend()
{
+ if (m_xdgShellSurface) {
+ m_xdgShellSurface->release();
+ }
if (m_shellSurface) {
m_shellSurface->release();
}
if (m_surface) {
m_surface->release();
}
+ if (m_xdgShell) {
+ m_xdgShell->release();
+ }
m_shell->release();
m_compositor->release();
m_registry->release();
@@ -361,6 +368,11 @@ void WaylandBackend::initConnection()
emit systemCompositorDied();
m_seat.reset();
m_shm->destroy();
+ if (m_xdgShellSurface) {
+ m_xdgShellSurface->destroy();
+ delete m_xdgShellSurface;
+ m_xdgShellSurface = nullptr;
+ }
if (m_shellSurface) {
m_shellSurface->destroy();
delete m_shellSurface;
@@ -374,6 +386,9 @@ void WaylandBackend::initConnection()
if (m_shell) {
m_shell->destroy();
}
+ if (m_xdgShell) {
+ m_xdgShell->destroy();
+ }
m_compositor->destroy();
m_registry->destroy();
m_eventQueue->destroy();
@@ -414,21 +429,41 @@ void WaylandBackend::createSurface()
if (m_seat) {
m_seat->setInstallCursor(true);
}
+ // check for xdg shell
+ auto xdgIface = m_registry->interface(Registry::Interface::XdgShellUnstableV5);
+ if (xdgIface.name != 0) {
+ m_xdgShell = m_registry->createXdgShell(xdgIface.name, xdgIface.version, this);
+ if (m_xdgShell && m_xdgShell->isValid()) {
+ m_xdgShellSurface = m_xdgShell->createSurface(m_surface, this);
+ connect(m_xdgShellSurface, &XdgShellSurface::closeRequested, qApp, &QCoreApplication::quit);
+ setupSurface(m_xdgShellSurface);
+ return;
+ }
+ }
if (m_shell->isValid()) {
m_shellSurface = m_shell->createSurface(m_surface, this);
- connect(m_shellSurface, &ShellSurface::sizeChanged, this, &WaylandBackend::shellSurfaceSizeChanged);
- m_shellSurface->setSize(initialWindowSize());
+ setupSurface(m_shellSurface);
m_shellSurface->setToplevel();
- setReady(true);
- emit screensQueried();
}
}
+template
+void WaylandBackend::setupSurface(T *surface)
+{
+ connect(surface, &T::sizeChanged, this, &WaylandBackend::shellSurfaceSizeChanged);
+ surface->setSize(initialWindowSize());
+ setReady(true);
+ emit screensQueried();
+}
+
QSize WaylandBackend::shellSurfaceSize() const
{
if (m_shellSurface) {
return m_shellSurface->size();
}
+ if (m_xdgShellSurface) {
+ return m_xdgShellSurface->size();
+ }
return QSize();
}
diff --git a/plugins/platforms/wayland/wayland_backend.h b/plugins/platforms/wayland/wayland_backend.h
index 606c031778..e7c77bcf3b 100644
--- a/plugins/platforms/wayland/wayland_backend.h
+++ b/plugins/platforms/wayland/wayland_backend.h
@@ -53,6 +53,8 @@ class Shell;
class ShellSurface;
class Surface;
class Touch;
+class XdgShell;
+class XdgShellSurface;
}
}
@@ -132,6 +134,8 @@ Q_SIGNALS:
private:
void initConnection();
void createSurface();
+ template
+ void setupSurface(T *surface);
wl_display *m_display;
KWayland::Client::EventQueue *m_eventQueue;
KWayland::Client::Registry *m_registry;
@@ -139,6 +143,8 @@ private:
KWayland::Client::Shell *m_shell;
KWayland::Client::Surface *m_surface;
KWayland::Client::ShellSurface *m_shellSurface;
+ KWayland::Client::XdgShell *m_xdgShell = nullptr;
+ KWayland::Client::XdgShellSurface *m_xdgShellSurface = nullptr;
QScopedPointer m_seat;
KWayland::Client::ShmPool *m_shm;
KWayland::Client::ConnectionThread *m_connectionThreadObject;