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
This commit is contained in:
Robert Mader 2019-06-13 20:16:37 +02:00
parent 57772e5850
commit 73bc3c4426
2 changed files with 19 additions and 0 deletions

View File

@ -86,5 +86,6 @@ void meta_window_actor_assign_surface_actor (MetaWindowActor *self,
MetaSurfaceActor *surface_actor); MetaSurfaceActor *surface_actor);
MetaWindowActor *meta_window_actor_from_window (MetaWindow *window); MetaWindowActor *meta_window_actor_from_window (MetaWindow *window);
MetaWindowActor *meta_window_actor_from_actor (ClutterActor *actor);
#endif /* META_WINDOW_ACTOR_PRIVATE_H */ #endif /* META_WINDOW_ACTOR_PRIVATE_H */

View File

@ -2035,3 +2035,21 @@ screen_cast_window_iface_init (MetaScreenCastWindowInterface *iface)
iface->capture_into = meta_window_actor_capture_into; iface->capture_into = meta_window_actor_capture_into;
iface->has_damage = meta_window_actor_has_damage; 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;
}