[mutter/wip/carlosg/grabs-pt1: 4/9] clutter: Only emit regular crossing events in the actors they make sense




commit 5aa2423b7b70b95ddf62d343f6ca9c51b07a6887
Author: Carlos Garnacho <carlosg gnome org>
Date:   Wed Oct 27 18:14:22 2021 +0200

    clutter: Only emit regular crossing events in the actors they make sense
    
    Instead of propagating ENTER/LEAVE all the way from the stage, emit those
    events only in the actors that are actually entered or left.

 clutter/clutter/clutter-stage.c | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)
---
diff --git a/clutter/clutter/clutter-stage.c b/clutter/clutter/clutter-stage.c
index 662a4c726d..a58c43d20c 100644
--- a/clutter/clutter/clutter-stage.c
+++ b/clutter/clutter/clutter-stage.c
@@ -3526,7 +3526,7 @@ clutter_stage_update_device (ClutterStage         *stage,
                              gboolean              emit_crossing)
 {
   ClutterInputDeviceType device_type;
-  ClutterActor *old_actor;
+  ClutterActor *old_actor, *root;
   gboolean device_actor_changed;
   ClutterEvent *event;
 
@@ -3553,6 +3553,24 @@ clutter_stage_update_device (ClutterStage         *stage,
                     point.y,
                     _clutter_actor_get_debug_name (new_actor));
 
+      if (emit_crossing)
+        {
+          ClutterActor *grab_actor;
+
+          root = find_common_root_actor (stage, new_actor, old_actor);
+
+          grab_actor = clutter_stage_get_grab_actor (stage);
+
+          /* If the common root is outside the currently effective grab,
+           * it involves actors outside the grabbed actor hierarchy, the
+           * events should be propagated from/inside the grab actor.
+           */
+          if (grab_actor &&
+              root != grab_actor &&
+              !clutter_actor_contains (grab_actor, root))
+            root = grab_actor;
+        }
+
       /* we need to make sure that this event is processed
        * before any other event we might have queued up until
        * now, so we go on, and synthesize the event emission
@@ -3566,7 +3584,8 @@ clutter_stage_update_device (ClutterStage         *stage,
                                          old_actor, new_actor,
                                          point, time_ms);
           if (!_clutter_event_process_filters (event))
-            _clutter_process_event (event);
+            _clutter_actor_handle_event (old_actor, root, event);
+
           clutter_event_free (event);
         }
 
@@ -3578,7 +3597,8 @@ clutter_stage_update_device (ClutterStage         *stage,
                                          new_actor, old_actor,
                                          point, time_ms);
           if (!_clutter_event_process_filters (event))
-            _clutter_process_event (event);
+            _clutter_actor_handle_event (new_actor, root, event);
+
           clutter_event_free (event);
         }
     }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]