[mutter/wip/carlosg/input-thread: 95/157] clutter: Pass base event to clutter_input_device_update()




commit 837b5fb33d43e1cb9c3b7fb169407aadb861f027
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sat Jun 6 12:35:47 2020 +0200

    clutter: Pass base event to clutter_input_device_update()
    
    So we may fetch coordinates without necessarily querying the device
    state.
    
    https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403

 clutter/clutter/clutter-input-device-private.h |  2 +-
 clutter/clutter/clutter-input-device.c         | 29 +++++++++++++++++++-------
 clutter/clutter/clutter-main.c                 |  8 +++----
 clutter/clutter/clutter-stage.c                |  3 +--
 4 files changed, 26 insertions(+), 16 deletions(-)
---
diff --git a/clutter/clutter/clutter-input-device-private.h b/clutter/clutter/clutter-input-device-private.h
index de2d4038f2..c63a1d4b7c 100644
--- a/clutter/clutter/clutter-input-device-private.h
+++ b/clutter/clutter/clutter-input-device-private.h
@@ -182,7 +182,7 @@ ClutterActor * clutter_input_device_update (ClutterInputDevice   *device,
                                             ClutterEventSequence *sequence,
                                             ClutterStage         *stage,
                                             gboolean              emit_crossing,
-                                            uint32_t              time_);
+                                            ClutterEvent         *for_event);
 CLUTTER_EXPORT
 void _clutter_input_device_add_event_sequence (ClutterInputDevice *device,
                                                ClutterEvent       *event);
diff --git a/clutter/clutter/clutter-input-device.c b/clutter/clutter/clutter-input-device.c
index 54518313f0..7bb3172a0d 100644
--- a/clutter/clutter/clutter-input-device.c
+++ b/clutter/clutter/clutter-input-device.c
@@ -714,6 +714,7 @@ _clutter_input_device_set_actor (ClutterInputDevice   *device,
                                  ClutterEventSequence *sequence,
                                  ClutterActor         *actor,
                                  gboolean              emit_crossing,
+                                 graphene_point_t      coords,
                                  uint32_t              time_)
 {
   ClutterActor *old_actor = clutter_input_device_get_actor (device, sequence);
@@ -746,8 +747,8 @@ _clutter_input_device_set_actor (ClutterInputDevice   *device,
           event->crossing.flags = 0;
           event->crossing.stage = stage;
           event->crossing.source = old_actor;
-          event->crossing.x = device->current_x;
-          event->crossing.y = device->current_y;
+          event->crossing.x = coords.x;
+          event->crossing.y = coords.y;
           event->crossing.related = actor;
           event->crossing.sequence = sequence;
           clutter_event_set_device (event, device);
@@ -782,8 +783,8 @@ _clutter_input_device_set_actor (ClutterInputDevice   *device,
           event->crossing.time = time_;
           event->crossing.flags = 0;
           event->crossing.stage = stage;
-          event->crossing.x = device->current_x;
-          event->crossing.y = device->current_y;
+          event->crossing.x = coords.x;
+          event->crossing.y = coords.y;
           event->crossing.source = actor;
           event->crossing.related = old_actor;
           event->crossing.sequence = sequence;
@@ -934,17 +935,27 @@ clutter_input_device_update (ClutterInputDevice   *device,
                              ClutterEventSequence *sequence,
                              ClutterStage         *stage,
                              gboolean              emit_crossing,
-                             uint32_t              time_)
+                             ClutterEvent         *for_event)
 {
   ClutterActor *new_cursor_actor;
   ClutterActor *old_cursor_actor;
   graphene_point_t point = GRAPHENE_POINT_INIT (-1.0f, -1.0f);
   ClutterInputDeviceType device_type = device->device_type;
+  uint32_t time_;
 
   g_assert (device_type != CLUTTER_KEYBOARD_DEVICE &&
             device_type != CLUTTER_PAD_DEVICE);
 
-  clutter_input_device_get_coords (device, sequence, &point);
+  if (for_event)
+    {
+      clutter_event_get_coords (for_event, &point.x, &point.y);
+      time_ = clutter_event_get_time (for_event);
+    }
+  else
+    {
+      clutter_input_device_get_coords (device, sequence, &point);
+      time_ = CLUTTER_CURRENT_TIME;
+    }
 
   old_cursor_actor = clutter_input_device_get_actor (device, sequence);
   new_cursor_actor =
@@ -972,7 +983,7 @@ clutter_input_device_update (ClutterInputDevice   *device,
   _clutter_input_device_set_actor (device, sequence,
                                    new_cursor_actor,
                                    emit_crossing,
-                                   time_);
+                                   point, time_);
 
   return new_cursor_actor;
 }
@@ -1564,12 +1575,14 @@ _clutter_input_device_remove_event_sequence (ClutterInputDevice *device,
     {
       GList *sequences =
         g_hash_table_lookup (device->inv_touch_sequence_actors, info->actor);
+      graphene_point_t point;
 
       sequences = g_list_remove (sequences, sequence);
 
       g_hash_table_replace (device->inv_touch_sequence_actors,
                             info->actor, sequences);
-      _clutter_input_device_set_actor (device, sequence, NULL, TRUE,
+      clutter_event_get_coords (event, &point.x, &point.y);
+      _clutter_input_device_set_actor (device, sequence, NULL, TRUE, point,
                                        clutter_event_get_time (event));
     }
 
diff --git a/clutter/clutter/clutter-main.c b/clutter/clutter/clutter-main.c
index 2dacec5af6..a90cadeaca 100644
--- a/clutter/clutter/clutter-main.c
+++ b/clutter/clutter/clutter-main.c
@@ -1626,7 +1626,7 @@ _clutter_process_event_details (ClutterActor        *stage,
 
             actor = clutter_input_device_update (device, NULL,
                                                  CLUTTER_STAGE (stage), FALSE,
-                                                 clutter_event_get_time (event));
+                                                 event);
             if (actor != stage)
               {
                 ClutterEvent *crossing;
@@ -1777,8 +1777,7 @@ _clutter_process_event_details (ClutterActor        *stage,
 
               actor = clutter_input_device_update (device, NULL,
                                                    CLUTTER_STAGE (stage),
-                                                   TRUE,
-                                                   clutter_event_get_time (event));
+                                                   TRUE, event);
               if (actor == NULL)
                 break;
 
@@ -1888,8 +1887,7 @@ _clutter_process_event_details (ClutterActor        *stage,
 
               actor = clutter_input_device_update (device, sequence,
                                                    CLUTTER_STAGE (stage),
-                                                   TRUE,
-                                                   clutter_event_get_time (event));
+                                                   TRUE, event);
               if (actor == NULL)
                 break;
 
diff --git a/clutter/clutter/clutter-stage.c b/clutter/clutter/clutter-stage.c
index 53489515da..b9b981b858 100644
--- a/clutter/clutter/clutter-stage.c
+++ b/clutter/clutter/clutter-stage.c
@@ -1361,8 +1361,7 @@ clutter_stage_update_devices (ClutterStage *stage,
   for (l = devices; l; l = l->next)
     {
       ClutterInputDevice *device = l->data;
-      clutter_input_device_update (device, NULL, stage, TRUE,
-                                   CLUTTER_CURRENT_TIME);
+      clutter_input_device_update (device, NULL, stage, TRUE, NULL);
     }
 }
 


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