[mutter/wip/carlosg/grabs-pt1: 3/16] clutter: Add parameter to control the event emission root
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/carlosg/grabs-pt1: 3/16] clutter: Add parameter to control the event emission root
- Date: Fri, 29 Oct 2021 11:07:50 +0000 (UTC)
commit 95d1d3a0d8a2f313467516e953fa532e15d3d5bf
Author: Carlos Garnacho <carlosg gnome org>
Date: Tue Oct 26 16:21:41 2021 +0200
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.
clutter/clutter/clutter-actor-private.h | 1 +
clutter/clutter/clutter-actor.c | 19 ++++++++++++++++++-
clutter/clutter/clutter-main.c | 2 +-
3 files changed, 20 insertions(+), 2 deletions(-)
---
diff --git a/clutter/clutter/clutter-actor-private.h b/clutter/clutter/clutter-actor-private.h
index 54371c6dde..a803166ace 100644
--- a/clutter/clutter/clutter-actor-private.h
+++ b/clutter/clutter/clutter-actor-private.h
@@ -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,
diff --git a/clutter/clutter/clutter-actor.c b/clutter/clutter/clutter-actor.c
index 6cbec0b70c..5e8c1068b5 100644
--- a/clutter/clutter/clutter-actor.c
+++ b/clutter/clutter/clutter-actor.c
@@ -18941,11 +18941,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,
@@ -18974,9 +18975,25 @@ _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;
}
+ /* If the event falls outside the given root, the events are meant
+ * to be ignored.
+ */
+ 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))
diff --git a/clutter/clutter/clutter-main.c b/clutter/clutter/clutter-main.c
index 567edfe261..9dc010b415 100644
--- a/clutter/clutter/clutter-main.c
+++ b/clutter/clutter/clutter-main.c
@@ -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);
}
/*
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]