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: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2717>
This commit is contained in:
Robert Mader 2022-11-02 19:35:35 +01:00 committed by Marge Bot
parent e0b2966dd0
commit 8af356c2c7

View File

@ -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;