From 8af356c2c791a236977bbcc347e8d4378b6587ea Mon Sep 17 00:00:00 2001 From: Robert Mader Date: Wed, 2 Nov 2022 19:35:35 +0100 Subject: [PATCH] wayland/subsurface: Implement meta_wayland_surface_get_window() Subsurfaces are special regarding windows as they don't have a window, but usually have an ancestor which does. All current users of `get_window()` are either used for known surface roles, such as xdg-* ones, or, as is the case for pointer constrains, would actually want to get the ancestors window. Thus implement `get_window()` to allow pointer constrains to work. Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2223 Part-of: --- src/wayland/meta-wayland-subsurface.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/wayland/meta-wayland-subsurface.c b/src/wayland/meta-wayland-subsurface.c index 63150d006..4feefae30 100644 --- a/src/wayland/meta-wayland-subsurface.c +++ b/src/wayland/meta-wayland-subsurface.c @@ -168,6 +168,20 @@ meta_wayland_subsurface_get_toplevel (MetaWaylandSurfaceRole *surface_role) return NULL; } +static MetaWindow * +meta_wayland_subsurface_get_window (MetaWaylandSurfaceRole *surface_role) +{ + MetaWaylandSurface *surface = + meta_wayland_surface_role_get_surface (surface_role); + MetaWaylandSurface *parent; + + parent = surface->protocol_state.parent; + if (parent) + return meta_wayland_surface_get_window (parent); + else + return NULL; +} + static gboolean meta_wayland_subsurface_is_synchronized (MetaWaylandSurfaceRole *surface_role) { @@ -252,6 +266,7 @@ meta_wayland_subsurface_class_init (MetaWaylandSubsurfaceClass *klass) surface_role_class->assigned = meta_wayland_subsurface_assigned; surface_role_class->get_toplevel = meta_wayland_subsurface_get_toplevel; + surface_role_class->get_window = meta_wayland_subsurface_get_window; surface_role_class->is_synchronized = meta_wayland_subsurface_is_synchronized; surface_role_class->notify_subsurface_state_changed = meta_wayland_subsurface_notify_subsurface_state_changed;