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




commit 8e742e0fcbe04d99f9fbcdb63decc444d4a9baf9
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 1e0c3da716..57787faa60 100644
--- a/clutter/clutter/clutter-stage.c
+++ b/clutter/clutter/clutter-stage.c
@@ -3528,7 +3528,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;
 
@@ -3555,6 +3555,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
@@ -3568,7 +3586,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);
         }
 
@@ -3580,7 +3599,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]