[mutter/wip/carlosg/grabs-pt1: 16/30] clutter: Shuffle code




commit d65ef98a03e3854c20e2b7a5982d3e23e9510802
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue Oct 26 14:18:24 2021 +0200

    clutter: Shuffle code
    
    This really belongs in ClutterStage. Move the code that updates the
    pointer actor there, as we want crossing event emission to stay close
    altogether.

 clutter/clutter/clutter-main.c          | 88 --------------------------------
 clutter/clutter/clutter-stage-private.h |  6 ---
 clutter/clutter/clutter-stage.c         | 90 ++++++++++++++++++++++++++++++++-
 3 files changed, 89 insertions(+), 95 deletions(-)
---
diff --git a/clutter/clutter/clutter-main.c b/clutter/clutter/clutter-main.c
index e5391ae840..567edfe261 100644
--- a/clutter/clutter/clutter-main.c
+++ b/clutter/clutter/clutter-main.c
@@ -824,94 +824,6 @@ clutter_do_event (ClutterEvent *event)
   _clutter_stage_queue_event (event->any.stage, event, TRUE);
 }
 
-static void
-create_crossing_event (ClutterStage         *stage,
-                       ClutterInputDevice   *device,
-                       ClutterEventSequence *sequence,
-                       ClutterEventType      event_type,
-                       ClutterActor         *source,
-                       ClutterActor         *related,
-                       graphene_point_t      coords,
-                       uint32_t              time)
-{
-  ClutterEvent *event;
-
-  event = clutter_event_new (event_type);
-  event->crossing.time = time;
-  event->crossing.flags = 0;
-  event->crossing.stage = stage;
-  event->crossing.source = source;
-  event->crossing.x = coords.x;
-  event->crossing.y = coords.y;
-  event->crossing.related = related;
-  event->crossing.sequence = sequence;
-  clutter_event_set_device (event, device);
-
-  /* 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
-   * ourselves
-   */
-  _clutter_process_event (event);
-
-  clutter_event_free (event);
-}
-
-void
-clutter_stage_update_device (ClutterStage         *stage,
-                             ClutterInputDevice   *device,
-                             ClutterEventSequence *sequence,
-                             graphene_point_t      point,
-                             uint32_t              time,
-                             ClutterActor         *new_actor,
-                             gboolean              emit_crossing)
-{
-  ClutterInputDeviceType device_type;
-  ClutterActor *old_actor;
-  gboolean device_actor_changed;
-
-  device_type = clutter_input_device_get_device_type (device);
-
-  g_assert (device_type != CLUTTER_KEYBOARD_DEVICE &&
-            device_type != CLUTTER_PAD_DEVICE);
-
-  old_actor = clutter_stage_get_device_actor (stage, device, sequence);
-  device_actor_changed = new_actor != old_actor;
-
-  clutter_stage_update_device_entry (stage,
-                                     device, sequence,
-                                     point,
-                                     new_actor);
-
-  if (device_actor_changed)
-    {
-      CLUTTER_NOTE (EVENT,
-                    "Updating actor under cursor (device %s, at %.2f, %.2f): %s",
-                    clutter_input_device_get_device_name (device),
-                    point.x,
-                    point.y,
-                    _clutter_actor_get_debug_name (new_actor));
-
-      if (old_actor && emit_crossing)
-        {
-          create_crossing_event (stage,
-                                 device, sequence,
-                                 CLUTTER_LEAVE,
-                                 old_actor, new_actor,
-                                 point, time);
-        }
-
-      if (new_actor && emit_crossing)
-        {
-          create_crossing_event (stage,
-                                 device, sequence,
-                                 CLUTTER_ENTER,
-                                 new_actor, old_actor,
-                                 point, time);
-        }
-    }
-}
-
 void
 clutter_stage_repick_device (ClutterStage       *stage,
                              ClutterInputDevice *device)
diff --git a/clutter/clutter/clutter-stage-private.h b/clutter/clutter/clutter-stage-private.h
index 690a360fa2..e5e1c81fa4 100644
--- a/clutter/clutter/clutter-stage-private.h
+++ b/clutter/clutter/clutter-stage-private.h
@@ -130,12 +130,6 @@ GList * clutter_stage_get_views_for_rect (ClutterStage          *stage,
 
 void clutter_stage_set_actor_needs_immediate_relayout (ClutterStage *stage);
 
-void clutter_stage_update_device_entry (ClutterStage         *self,
-                                        ClutterInputDevice   *device,
-                                        ClutterEventSequence *sequence,
-                                        graphene_point_t      coords,
-                                        ClutterActor         *actor);
-
 void clutter_stage_remove_device_entry (ClutterStage         *self,
                                         ClutterInputDevice   *device,
                                         ClutterEventSequence *sequence);
diff --git a/clutter/clutter/clutter-stage.c b/clutter/clutter/clutter-stage.c
index f129a7aebf..6101ec5a5d 100644
--- a/clutter/clutter/clutter-stage.c
+++ b/clutter/clutter/clutter-stage.c
@@ -3311,7 +3311,7 @@ free_pointer_device_entry (PointerDeviceEntry *entry)
   g_free (entry);
 }
 
-void
+static void
 clutter_stage_update_device_entry (ClutterStage         *self,
                                    ClutterInputDevice   *device,
                                    ClutterEventSequence *sequence,
@@ -3425,6 +3425,94 @@ clutter_stage_get_device_actor (ClutterStage         *stage,
   return NULL;
 }
 
+static void
+create_crossing_event (ClutterStage         *stage,
+                       ClutterInputDevice   *device,
+                       ClutterEventSequence *sequence,
+                       ClutterEventType      event_type,
+                       ClutterActor         *source,
+                       ClutterActor         *related,
+                       graphene_point_t      coords,
+                       uint32_t              time)
+{
+  ClutterEvent *event;
+
+  event = clutter_event_new (event_type);
+  event->crossing.time = time;
+  event->crossing.flags = 0;
+  event->crossing.stage = stage;
+  event->crossing.source = source;
+  event->crossing.x = coords.x;
+  event->crossing.y = coords.y;
+  event->crossing.related = related;
+  event->crossing.sequence = sequence;
+  clutter_event_set_device (event, device);
+
+  /* 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
+   * ourselves
+   */
+  _clutter_process_event (event);
+
+  clutter_event_free (event);
+}
+
+void
+clutter_stage_update_device (ClutterStage         *stage,
+                             ClutterInputDevice   *device,
+                             ClutterEventSequence *sequence,
+                             graphene_point_t      point,
+                             uint32_t              time,
+                             ClutterActor         *new_actor,
+                             gboolean              emit_crossing)
+{
+  ClutterInputDeviceType device_type;
+  ClutterActor *old_actor;
+  gboolean device_actor_changed;
+
+  device_type = clutter_input_device_get_device_type (device);
+
+  g_assert (device_type != CLUTTER_KEYBOARD_DEVICE &&
+            device_type != CLUTTER_PAD_DEVICE);
+
+  old_actor = clutter_stage_get_device_actor (stage, device, sequence);
+  device_actor_changed = new_actor != old_actor;
+
+  clutter_stage_update_device_entry (stage,
+                                     device, sequence,
+                                     point,
+                                     new_actor);
+
+  if (device_actor_changed)
+    {
+      CLUTTER_NOTE (EVENT,
+                    "Updating actor under cursor (device %s, at %.2f, %.2f): %s",
+                    clutter_input_device_get_device_name (device),
+                    point.x,
+                    point.y,
+                    _clutter_actor_get_debug_name (new_actor));
+
+      if (old_actor && emit_crossing)
+        {
+          create_crossing_event (stage,
+                                 device, sequence,
+                                 CLUTTER_LEAVE,
+                                 old_actor, new_actor,
+                                 point, time);
+        }
+
+      if (new_actor && emit_crossing)
+        {
+          create_crossing_event (stage,
+                                 device, sequence,
+                                 CLUTTER_ENTER,
+                                 new_actor, old_actor,
+                                 point, time);
+        }
+    }
+}
+
 /**
  * clutter_stage_get_device_coords: (skip):
  */


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