From 9e58301df7f09660cb36337211cbf5700d99810c Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Tue, 1 Jun 2021 12:18:53 +0200 Subject: surface: allow placing subsurfaces below parent Prior to this commit, subsurfaces could only be placed above their parent. Any place_{above,below} request involving the parent would fail with a protocol error. However the Wayland protocol allows using the parent surface in the place_{above,below} requests, and allows subsurfaces to be placed below their parent. Weston's implementation adds a dummy wl_list node in the subsurface list. However this is potentially dangerous: iterating the list requires making sure the dummy wl_list node is checked for, otherwise memory corruption will happen. Instead, split the list in two: one for subsurfaces above the parent, the other for subsurfaces below. Tested with wleird's subsurfaces demo client. Closes: https://github.com/swaywm/wlroots/issues/1865 --- include/wlr/types/wlr_surface.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'include/wlr') diff --git a/include/wlr/types/wlr_surface.h b/include/wlr/types/wlr_surface.h index d99c182a..00db6cd8 100644 --- a/include/wlr/types/wlr_surface.h +++ b/include/wlr/types/wlr_surface.h @@ -139,10 +139,13 @@ struct wlr_surface { struct wl_signal destroy; } events; - struct wl_list subsurfaces; // wlr_subsurface::parent_link + // wlr_subsurface.parent_link + struct wl_list subsurfaces_below; + struct wl_list subsurfaces_above; - // wlr_subsurface::parent_pending_link - struct wl_list subsurface_pending_list; + // wlr_subsurface.parent_pending_link + struct wl_list subsurfaces_pending_below; + struct wl_list subsurfaces_pending_above; struct wl_list current_outputs; // wlr_surface_output::link -- cgit v1.2.3