From 1943de850159d6d471b7a031f9994ccb83f99f2c Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Wed, 8 Mar 2023 12:27:49 +0200 Subject: [PATCH] Add a (temporary) way to attach popups to layer surfaces The new API is temporary. It's needed to help us with porting plasma to the layer shell protocol until Qt 6.6 is released, which includes QWaylandShellSurface::attachPopup(). --- src/interfaces/window.cpp | 18 ++++++++++++++++++ src/interfaces/window.h | 8 ++++++++ 2 files changed, 26 insertions(+) diff --git a/src/interfaces/window.cpp b/src/interfaces/window.cpp index 1ae037e..9f582bb 100644 --- a/src/interfaces/window.cpp +++ b/src/interfaces/window.cpp @@ -6,6 +6,9 @@ #include "window.h" #include "../qwaylandlayershellintegration_p.h" +#if QT_VERSION < QT_VERSION_CHECK(6, 6, 0) +#include "../qwaylandlayersurface_p.h" +#endif #include @@ -121,6 +124,21 @@ void Window::setDesiredOutput(QScreen *output) d->desiredOutput = output; } +#if QT_VERSION < QT_VERSION_CHECK(6, 6, 0) +void Window::attachPopup(QWindow *window, xdg_popup *popup) +{ + auto waylandWindow = dynamic_cast(window->handle()); + if (!waylandWindow) { + return; + } + + auto shellSurface = dynamic_cast(waylandWindow->shellSurface()); + if (shellSurface) { + shellSurface->get_popup(popup); + } +} +#endif + Window::Window(QWindow *window) : QObject(window) , d(new WindowPrivate(window)) diff --git a/src/interfaces/window.h b/src/interfaces/window.h index 5ebc9b1..72e3b8c 100644 --- a/src/interfaces/window.h +++ b/src/interfaces/window.h @@ -14,6 +14,10 @@ #include "layershellqt_export.h" +#if QT_VERSION < QT_VERSION_CHECK(6, 6, 0) +struct xdg_popup; +#endif + namespace LayerShellQt { class WindowPrivate; @@ -93,6 +97,10 @@ public: */ static Window *get(QWindow *window); +#if QT_VERSION < QT_VERSION_CHECK(6, 6, 0) + static void attachPopup(QWindow *window, xdg_popup *popup); +#endif + Q_SIGNALS: void anchorsChanged(); void exclusionZoneChanged();