[mutter/wip/carlosg/input-thread: 96/97] backends/native: Acknowledge that pointer warping is asynchronous




commit ac91ee0cb174409aae2468592602aa64af4e1b38
Author: Carlos Garnacho <carlosg gnome org>
Date:   Wed Oct 28 19:47:35 2020 +0100

    backends/native: Acknowledge that pointer warping is asynchronous
    
    Update the cursor tracker/renderer after the warping has been performed,
    not while it's still in flight.
    
    https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403

 src/backends/native/meta-seat-impl.c   | 10 ++++++----
 src/backends/native/meta-seat-impl.h   |  8 +++++---
 src/backends/native/meta-seat-native.c | 23 +++++++++++++++++------
 3 files changed, 28 insertions(+), 13 deletions(-)
---
diff --git a/src/backends/native/meta-seat-impl.c b/src/backends/native/meta-seat-impl.c
index 5cae66eb3c..99655dd867 100644
--- a/src/backends/native/meta-seat-impl.c
+++ b/src/backends/native/meta-seat-impl.c
@@ -2727,9 +2727,11 @@ warp_pointer (GTask *task)
 }
 
 void
-meta_seat_impl_warp_pointer (MetaSeatImpl *seat,
-                             int           x,
-                             int           y)
+meta_seat_impl_warp_pointer (MetaSeatImpl        *seat,
+                             int                  x,
+                             int                  y,
+                             GAsyncReadyCallback  cb,
+                             gpointer             data)
 {
   graphene_point_t *point;
   GTask *task;
@@ -2738,7 +2740,7 @@ meta_seat_impl_warp_pointer (MetaSeatImpl *seat,
   point->x = x;
   point->y = y;
 
-  task = g_task_new (seat, NULL, NULL, NULL);
+  task = g_task_new (seat, NULL, cb, data);
   g_task_set_task_data (task, point, (GDestroyNotify) graphene_point_free);
   meta_seat_impl_run_input_task (seat, task, (GSourceFunc) warp_pointer);
   g_object_unref (task);
diff --git a/src/backends/native/meta-seat-impl.h b/src/backends/native/meta-seat-impl.h
index a43582e31b..2576c08dfa 100644
--- a/src/backends/native/meta-seat-impl.h
+++ b/src/backends/native/meta-seat-impl.h
@@ -241,9 +241,11 @@ void meta_seat_impl_set_pointer_constraint (MetaSeatImpl              *seat,
 void meta_seat_impl_set_viewports (MetaSeatImpl     *seat,
                                    MetaViewportInfo *viewports);
 
-void meta_seat_impl_warp_pointer (MetaSeatImpl *seat,
-                                  int           x,
-                                  int           y);
+void meta_seat_impl_warp_pointer (MetaSeatImpl        *seat,
+                                  int                  x,
+                                  int                  y,
+                                  GAsyncReadyCallback  cb,
+                                  gpointer             data);
 ClutterVirtualInputDevice *
 meta_seat_impl_create_virtual_device (MetaSeatImpl           *seat,
                                       ClutterInputDeviceType  device_type);
diff --git a/src/backends/native/meta-seat-native.c b/src/backends/native/meta-seat-native.c
index ded5d85f48..0c980bac06 100644
--- a/src/backends/native/meta-seat-native.c
+++ b/src/backends/native/meta-seat-native.c
@@ -398,21 +398,32 @@ meta_seat_native_compress_motion (ClutterSeat        *seat,
 }
 
 static void
-meta_seat_native_warp_pointer (ClutterSeat *seat,
-                               int          x,
-                               int          y)
+warp_pointer_cb (MetaSeatImpl *impl,
+                 GAsyncResult *res,
+                 gpointer      user_data)
 {
-  MetaSeatNative *seat_native = META_SEAT_NATIVE (seat);
-  MetaBackend *backend = meta_get_backend ();
+  MetaBackend *backend = user_data;
   MetaCursorRenderer *cursor_renderer =
     meta_backend_get_cursor_renderer (backend);
   MetaCursorTracker *cursor_tracker = meta_backend_get_cursor_tracker (backend);
 
-  meta_seat_impl_warp_pointer (seat_native->impl, x, y);
   meta_cursor_renderer_update_position (cursor_renderer);
   meta_cursor_tracker_update_position (cursor_tracker);
 }
 
+static void
+meta_seat_native_warp_pointer (ClutterSeat *seat,
+                               int          x,
+                               int          y)
+{
+  MetaSeatNative *seat_native = META_SEAT_NATIVE (seat);
+  MetaBackend *backend = meta_get_backend ();
+
+  meta_seat_impl_warp_pointer (seat_native->impl, x, y,
+                               (GAsyncReadyCallback ) warp_pointer_cb,
+                               backend);
+}
+
 static gboolean
 meta_seat_native_query_state (ClutterSeat          *seat,
                               ClutterInputDevice   *device,


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