From 73bc3c4426776c85177413762498d7e9bd1e059d Mon Sep 17 00:00:00 2001 From: Robert Mader Date: Thu, 13 Jun 2019 20:16:37 +0200 Subject: [PATCH] window-actor: Add API to get a MetaWindowActor from a ClutterActor Make it so it returns the closest ancestry MetaWindowActor if it is a MetaSurfaceActor. We need this for Wayland subsurfaces, so we can support actions like Meta+Drag on them. https://gitlab.gnome.org/GNOME/mutter/merge_requests/604 --- src/compositor/meta-window-actor-private.h | 1 + src/compositor/meta-window-actor.c | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/compositor/meta-window-actor-private.h b/src/compositor/meta-window-actor-private.h index 396e84a8a..24a4cfcb6 100644 --- a/src/compositor/meta-window-actor-private.h +++ b/src/compositor/meta-window-actor-private.h @@ -86,5 +86,6 @@ void meta_window_actor_assign_surface_actor (MetaWindowActor *self, MetaSurfaceActor *surface_actor); MetaWindowActor *meta_window_actor_from_window (MetaWindow *window); +MetaWindowActor *meta_window_actor_from_actor (ClutterActor *actor); #endif /* META_WINDOW_ACTOR_PRIVATE_H */ diff --git a/src/compositor/meta-window-actor.c b/src/compositor/meta-window-actor.c index f558bfd1b..84c282e18 100644 --- a/src/compositor/meta-window-actor.c +++ b/src/compositor/meta-window-actor.c @@ -2035,3 +2035,21 @@ screen_cast_window_iface_init (MetaScreenCastWindowInterface *iface) iface->capture_into = meta_window_actor_capture_into; iface->has_damage = meta_window_actor_has_damage; } + +MetaWindowActor * +meta_window_actor_from_actor (ClutterActor *actor) +{ + if (!META_IS_SURFACE_ACTOR (actor)) + return NULL; + + do + { + actor = clutter_actor_get_parent (actor); + + if (META_IS_WINDOW_ACTOR (actor)) + return META_WINDOW_ACTOR (actor); + } + while (actor != NULL); + + return NULL; +}