clutter: Add parameter to control the event emission root

Grabs will alter the topmost actor from where it makes sense to emit
events, add infrastructure so we can tell which actor is that when
emitting a ClutterEvent.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2068>
This commit is contained in:
Carlos Garnacho 2021-10-26 16:21:41 +02:00 committed by Marge Bot
parent bbc95c1688
commit a60658f15e
3 changed files with 21 additions and 2 deletions

View File

@ -246,6 +246,7 @@ void _clutter_actor_pop_clone_paint
ClutterActorAlign _clutter_actor_get_effective_x_align (ClutterActor *self);
void _clutter_actor_handle_event (ClutterActor *actor,
ClutterActor *root,
const ClutterEvent *event);
void _clutter_actor_attach_clone (ClutterActor *actor,

View File

@ -18992,11 +18992,12 @@ clutter_actor_get_content_repeat (ClutterActor *self)
void
_clutter_actor_handle_event (ClutterActor *self,
ClutterActor *root,
const ClutterEvent *event)
{
GPtrArray *event_tree;
ClutterActor *iter;
gboolean is_key_event;
gboolean is_key_event, in_root = FALSE;
gint i = 0;
/* XXX - for historical reasons that are now lost in the mists of time,
@ -19025,9 +19026,26 @@ _clutter_actor_handle_event (ClutterActor *self,
g_ptr_array_add (event_tree, g_object_ref (iter));
}
if (iter == root)
{
in_root = TRUE;
break;
}
iter = parent;
}
/* The grab root conceptually extends infinitely in all
* directions, so it handles the events that fall outside of
* the actor.
*/
if (root && !in_root)
{
if (!clutter_actor_event (root, event, TRUE))
clutter_actor_event (root, event, FALSE);
goto done;
}
/* Capture: from top-level downwards */
for (i = event_tree->len - 1; i >= 0; i--)
if (clutter_actor_event (g_ptr_array_index (event_tree, i), event, TRUE))

View File

@ -683,7 +683,7 @@ emit_event_chain (ClutterEvent *event)
return;
}
_clutter_actor_handle_event (event->any.source, event);
_clutter_actor_handle_event (event->any.source, NULL, event);
}
/*