summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVlad Zahorodnii <vlad.zahorodnii@kde.org>2023-03-27 14:33:31 +0300
committerVlad Zahorodnii <vlad.zahorodnii@kde.org>2023-04-03 15:14:04 +0300
commitfa1a070cf690a5ffe9867bc0cc8d3d502f7cf0b6 (patch)
tree4b665804352476066b547a88159c991425e167b7 /src
parente7bc521fba30581546edae26be84de10c2f2a0f9 (diff)
downloadqtwayland-fa1a070cf690a5ffe9867bc0cc8d3d502f7cf0b6.tar.gz
Client: Provide hooks for parent windows to attach popups to them
The xdg-shell protocol allows to attach xdg_popups to parent surfaces that are not xdg_surfaces. For example, in order to attach an xdg_popup to a layer_surface, you would need to initialize the popup as follows xdg_popup popup = xdg_surface.get_popup(nil, positioner) zwlr_layer_surface_v1.get_popup(popup) QWaylandShellSurface::attachPopup() provides a way to perform parent-specific initialization, i.e. call zwlr_layer_surface_v1.get_popup. QWaylandShellSurface::detachPopup() was added mostly for futureproofing. The xdg-shell doesn't say exactly how the parent surface must be attached. In the example provided above, a request is used to associate the popup with its parent layer surface. But one could also create an object to represent the relationship between the two. The detachPopup() hook can be used to call the destructor request for that object. Change-Id: I43b10e77bd70751d8b4c3a0b5e1d294690bc471a Reviewed-by: David Edmundson <davidedmundson@kde.org>
Diffstat (limited to 'src')
-rw-r--r--src/client/qwaylandshellsurface_p.h3
-rw-r--r--src/client/qwaylandwindow.cpp4
2 files changed, 7 insertions, 0 deletions
diff --git a/src/client/qwaylandshellsurface_p.h b/src/client/qwaylandshellsurface_p.h
index 51116c52..6499a2bb 100644
--- a/src/client/qwaylandshellsurface_p.h
+++ b/src/client/qwaylandshellsurface_p.h
@@ -84,6 +84,9 @@ public:
virtual std::any surfaceRole() const { return std::any(); };
+ virtual void attachPopup(QWaylandShellSurface *popup) { Q_UNUSED(popup); }
+ virtual void detachPopup(QWaylandShellSurface *popup) { Q_UNUSED(popup); }
+
protected:
void resizeFromApplyConfigure(const QSize &sizeWithMargins, const QPoint &offset = {0, 0});
void repositionFromApplyConfigure(const QPoint &position);
diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp
index 74db519f..c48c9ddd 100644
--- a/src/client/qwaylandwindow.cpp
+++ b/src/client/qwaylandwindow.cpp
@@ -1635,11 +1635,15 @@ void QWaylandWindow::setXdgActivationToken(const QString &token)
void QWaylandWindow::addChildPopup(QWaylandWindow *child)
{
+ if (mShellSurface)
+ mShellSurface->attachPopup(child->shellSurface());
mChildPopups.append(child);
}
void QWaylandWindow::removeChildPopup(QWaylandWindow *child)
{
+ if (mShellSurface)
+ mShellSurface->detachPopup(child->shellSurface());
mChildPopups.removeAll(child);
}