[mutter/wip/carlosg/grabs-pt1: 11/22] clutter: Add parameter to control the event emission root




commit 3ffceab397dd42f3baba6752641b9dac94b2b395
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 2c69f0ad67..82fb50ca42 100644
--- a/clutter/clutter/clutter-actor.c
+++ b/clutter/clutter/clutter-actor.c
@@ -18961,11 +18961,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,
@@ -18994,9 +18995,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]