[mutter/wip/carlosg/clutter-seat: 43/43] backends: Move warp_pointer() to ClutterSeat



commit 61828e5e4cecbe48c7e56663bf314296e5ea1f60
Author: Carlos Garnacho <carlosg gnome org>
Date:   Wed Oct 9 18:01:34 2019 +0200

    backends: Move warp_pointer() to ClutterSeat
    
    The onscreen pointer sprite is a per-seat element, so it makes sense
    to move pointer warping over there too.

 clutter/clutter/clutter-seat.c                 | 10 ++++++
 clutter/clutter/clutter-seat.h                 |  9 ++++++
 src/backends/meta-backend-private.h            |  8 -----
 src/backends/meta-backend.c                    | 14 ++-------
 src/backends/native/meta-backend-native.c      | 21 -------------
 src/backends/native/meta-seat-native.c         | 43 ++++++++++----------------
 src/backends/native/meta-seat-native.h         |  5 ---
 src/backends/x11/meta-backend-x11.c            | 17 ----------
 src/backends/x11/meta-seat-x11.c               | 16 ++++++++++
 src/core/window.c                              |  6 ++--
 src/wayland/meta-pointer-confinement-wayland.c |  5 ++-
 src/wayland/meta-wayland-pointer-constraints.c |  7 ++++-
 12 files changed, 67 insertions(+), 94 deletions(-)
---
diff --git a/clutter/clutter/clutter-seat.c b/clutter/clutter/clutter-seat.c
index 884e44eac..8a75c9396 100644
--- a/clutter/clutter/clutter-seat.c
+++ b/clutter/clutter/clutter-seat.c
@@ -556,3 +556,13 @@ clutter_seat_compress_motion (ClutterSeat        *seat,
 
   seat_class->compress_motion (seat, event, to_discard);
 }
+
+void
+clutter_seat_warp_pointer (ClutterSeat *seat,
+                           int          x,
+                           int          y)
+{
+  g_return_if_fail (CLUTTER_IS_SEAT (seat));
+
+  CLUTTER_SEAT_GET_CLASS (seat)->warp_pointer (seat, x, y);
+}
diff --git a/clutter/clutter/clutter-seat.h b/clutter/clutter/clutter-seat.h
index 916e61d57..f8754f647 100644
--- a/clutter/clutter/clutter-seat.h
+++ b/clutter/clutter/clutter-seat.h
@@ -106,6 +106,10 @@ struct _ClutterSeatClass
                             ClutterEvent       *event,
                             const ClutterEvent *to_discard);
 
+  void (* warp_pointer) (ClutterSeat *seat,
+                         int          x,
+                         int          y);
+
   /* Event platform data */
   void (* copy_event_data) (ClutterSeat        *seat,
                             const ClutterEvent *src,
@@ -166,4 +170,9 @@ void clutter_seat_compress_motion (ClutterSeat        *seat,
                                    ClutterEvent       *event,
                                    const ClutterEvent *to_discard);
 
+CLUTTER_EXPORT
+void clutter_seat_warp_pointer (ClutterSeat *seat,
+                                int          x,
+                                int          y);
+
 #endif /* CLUTTER_SEAT_H */
diff --git a/src/backends/meta-backend-private.h b/src/backends/meta-backend-private.h
index cf6423f69..c48e428a8 100644
--- a/src/backends/meta-backend-private.h
+++ b/src/backends/meta-backend-private.h
@@ -71,10 +71,6 @@ struct _MetaBackendClass
                               int          device_id,
                               uint32_t     timestamp);
 
-  void (* warp_pointer) (MetaBackend *backend,
-                         int          x,
-                         int          y);
-
   MetaLogicalMonitor * (* get_current_logical_monitor) (MetaBackend *backend);
 
   void (* set_keymap) (MetaBackend *backend,
@@ -129,10 +125,6 @@ gboolean meta_backend_ungrab_device (MetaBackend *backend,
                                      int          device_id,
                                      uint32_t     timestamp);
 
-void meta_backend_warp_pointer (MetaBackend *backend,
-                                int          x,
-                                int          y);
-
 MetaLogicalMonitor * meta_backend_get_current_logical_monitor (MetaBackend *backend);
 
 struct xkb_keymap * meta_backend_get_keymap (MetaBackend *backend);
diff --git a/src/backends/meta-backend.c b/src/backends/meta-backend.c
index 9c8c04f1c..db35e0445 100644
--- a/src/backends/meta-backend.c
+++ b/src/backends/meta-backend.c
@@ -238,6 +238,7 @@ reset_pointer_position (MetaBackend *backend)
 {
   MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
   MetaMonitorManager *monitor_manager = priv->monitor_manager;
+  ClutterSeat *seat = clutter_backend_get_default_seat (priv->clutter_backend);
   MetaLogicalMonitor *primary;
 
   primary =
@@ -245,7 +246,7 @@ reset_pointer_position (MetaBackend *backend)
 
   /* Move the pointer out of the way to avoid hovering over reactive
    * elements (e.g. users list at login) causing undesired behaviour. */
-  meta_backend_warp_pointer (backend,
+  clutter_seat_warp_pointer (seat,
                              primary->rect.x + primary->rect.width * 0.9,
                              primary->rect.y + primary->rect.height * 0.9);
 }
@@ -1054,17 +1055,6 @@ meta_backend_ungrab_device (MetaBackend *backend,
   return META_BACKEND_GET_CLASS (backend)->ungrab_device (backend, device_id, timestamp);
 }
 
-/**
- * meta_backend_warp_pointer: (skip)
- */
-void
-meta_backend_warp_pointer (MetaBackend *backend,
-                           int          x,
-                           int          y)
-{
-  META_BACKEND_GET_CLASS (backend)->warp_pointer (backend, x, y);
-}
-
 MetaLogicalMonitor *
 meta_backend_get_current_logical_monitor (MetaBackend *backend)
 {
diff --git a/src/backends/native/meta-backend-native.c b/src/backends/native/meta-backend-native.c
index 97adb0a18..ac4878e57 100644
--- a/src/backends/native/meta-backend-native.c
+++ b/src/backends/native/meta-backend-native.c
@@ -403,25 +403,6 @@ meta_backend_native_create_input_settings (MetaBackend *backend)
   return g_object_new (META_TYPE_INPUT_SETTINGS_NATIVE, NULL);
 }
 
-static void
-meta_backend_native_warp_pointer (MetaBackend *backend,
-                                  int          x,
-                                  int          y)
-{
-  ClutterSeat *seat = clutter_backend_get_default_seat (clutter_get_default_backend ());
-  ClutterInputDevice *device = clutter_seat_get_pointer (seat);
-  MetaCursorTracker *cursor_tracker = meta_backend_get_cursor_tracker (backend);
-
-  /* XXX */
-  guint32 time_ = 0;
-
-  /* Warp the input device pointer state. */
-  meta_seat_native_warp_pointer (device, time_, x, y);
-
-  /* Warp displayed pointer cursor. */
-  meta_cursor_tracker_update_position (cursor_tracker, x, y);
-}
-
 static MetaLogicalMonitor *
 meta_backend_native_get_current_logical_monitor (MetaBackend *backend)
 {
@@ -707,8 +688,6 @@ meta_backend_native_class_init (MetaBackendNativeClass *klass)
   backend_class->create_renderer = meta_backend_native_create_renderer;
   backend_class->create_input_settings = meta_backend_native_create_input_settings;
 
-  backend_class->warp_pointer = meta_backend_native_warp_pointer;
-
   backend_class->get_current_logical_monitor = meta_backend_native_get_current_logical_monitor;
 
   backend_class->set_keymap = meta_backend_native_set_keymap;
diff --git a/src/backends/native/meta-seat-native.c b/src/backends/native/meta-seat-native.c
index 07143db9a..2c8e360cb 100644
--- a/src/backends/native/meta-seat-native.c
+++ b/src/backends/native/meta-seat-native.c
@@ -32,6 +32,7 @@
 #include <linux/input.h>
 #include <math.h>
 
+#include "backends/meta-cursor-tracker-private.h"
 #include "backends/native/meta-seat-native.h"
 #include "backends/native/meta-event-native.h"
 #include "backends/native/meta-input-device-native.h"
@@ -2624,6 +2625,20 @@ meta_seat_native_compress_motion (ClutterSeat        *seat,
                                          dy_unaccel + dst_dy_unaccel);
 }
 
+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 ();
+  MetaCursorTracker *cursor_tracker = meta_backend_get_cursor_tracker (backend);
+
+  notify_absolute_motion (seat_native->core_pointer, 0, x, y, NULL);
+
+  meta_cursor_tracker_update_position (cursor_tracker, x, y);
+}
+
 static void
 meta_seat_native_class_init (MetaSeatNativeClass *klass)
 {
@@ -2647,6 +2662,7 @@ meta_seat_native_class_init (MetaSeatNativeClass *klass)
   seat_class->create_virtual_device = meta_seat_native_create_virtual_device;
   seat_class->get_supported_virtual_device_types = meta_seat_native_get_supported_virtual_device_types;
   seat_class->compress_motion = meta_seat_native_compress_motion;
+  seat_class->warp_pointer = meta_seat_native_warp_pointer;
 
   props[PROP_SEAT_ID] =
     g_param_spec_string ("seat-id",
@@ -2932,33 +2948,6 @@ meta_seat_native_update_xkb_state (MetaSeatNative *seat)
   meta_seat_native_sync_leds (seat);
 }
 
-/**
- * meta_seat_native_warp_pointer:
- * @pointer_device: the pointer device to warp
- * @time: the timestamp for the warp event
- * @x: the new X position of the pointer
- * @y: the new Y position of the pointer
- *
- * Warps the pointer to a new location. Technically, this is
- * processed the same way as an absolute motion event from
- * libinput: it simply generates an absolute motion event that
- * will be processed on the next iteration of the mainloop.
- *
- * The intended use for this is for display servers that need
- * to warp cursor the cursor to a new location.
- *
- * Since: 1.20
- * Stability: unstable
- */
-void
-meta_seat_native_warp_pointer (ClutterInputDevice   *pointer_device,
-                               uint32_t              time_,
-                               int                   x,
-                               int                   y)
-{
-  notify_absolute_motion (pointer_device, ms2us(time_), x, y, NULL);
-}
-
 gint
 meta_seat_native_acquire_device_id (MetaSeatNative *seat)
 {
diff --git a/src/backends/native/meta-seat-native.h b/src/backends/native/meta-seat-native.h
index 0ed4afd95..e35eaa437 100644
--- a/src/backends/native/meta-seat-native.h
+++ b/src/backends/native/meta-seat-native.h
@@ -295,11 +295,6 @@ void meta_seat_native_remove_filter (MetaSeatNative        *seat,
                                      MetaEvdevFilterFunc    func,
                                      gpointer               data);
 
-void meta_seat_native_warp_pointer (ClutterInputDevice   *pointer_device,
-                                    uint32_t              time_,
-                                    int                   x,
-                                    int                   y);
-
 struct xkb_state * meta_seat_native_get_xkb_state (MetaSeatNative *seat);
 
 void               meta_seat_native_set_keyboard_map   (MetaSeatNative    *seat,
diff --git a/src/backends/x11/meta-backend-x11.c b/src/backends/x11/meta-backend-x11.c
index 7dc26f940..e11e4c143 100644
--- a/src/backends/x11/meta-backend-x11.c
+++ b/src/backends/x11/meta-backend-x11.c
@@ -597,22 +597,6 @@ meta_backend_x11_ungrab_device (MetaBackend *backend,
   return (ret == Success);
 }
 
-static void
-meta_backend_x11_warp_pointer (MetaBackend *backend,
-                               int          x,
-                               int          y)
-{
-  MetaBackendX11 *x11 = META_BACKEND_X11 (backend);
-  MetaBackendX11Private *priv = meta_backend_x11_get_instance_private (x11);
-
-  XIWarpPointer (priv->xdisplay,
-                 META_VIRTUAL_CORE_POINTER_ID,
-                 None,
-                 meta_backend_x11_get_xwindow (x11),
-                 0, 0, 0, 0,
-                 x, y);
-}
-
 static MetaLogicalMonitor *
 meta_backend_x11_get_current_logical_monitor (MetaBackend *backend)
 {
@@ -788,7 +772,6 @@ meta_backend_x11_class_init (MetaBackendX11Class *klass)
   backend_class->post_init = meta_backend_x11_post_init;
   backend_class->grab_device = meta_backend_x11_grab_device;
   backend_class->ungrab_device = meta_backend_x11_ungrab_device;
-  backend_class->warp_pointer = meta_backend_x11_warp_pointer;
   backend_class->get_current_logical_monitor = meta_backend_x11_get_current_logical_monitor;
   backend_class->get_keymap = meta_backend_x11_get_keymap;
   backend_class->get_keymap_layout_group = meta_backend_x11_get_keymap_layout_group;
diff --git a/src/backends/x11/meta-seat-x11.c b/src/backends/x11/meta-seat-x11.c
index 555f2adbe..183a80e4f 100644
--- a/src/backends/x11/meta-seat-x11.c
+++ b/src/backends/x11/meta-seat-x11.c
@@ -1500,6 +1500,21 @@ meta_seat_x11_get_supported_virtual_device_types (ClutterSeat *seat)
           CLUTTER_VIRTUAL_DEVICE_TYPE_POINTER);
 }
 
+static void
+meta_seat_x11_warp_pointer (ClutterSeat *seat,
+                            int          x,
+                            int          y)
+{
+  MetaSeatX11 *seat_x11 = META_SEAT_X11 (seat);
+
+  XIWarpPointer (clutter_x11_get_default_display (),
+                 seat_x11->pointer_id,
+                 None,
+                 clutter_x11_get_root_window (),
+                 0, 0, 0, 0,
+                 x, y);
+}
+
 static void
 meta_seat_x11_class_init (MetaSeatX11Class *klass)
 {
@@ -1521,6 +1536,7 @@ meta_seat_x11_class_init (MetaSeatX11Class *klass)
   seat_class->apply_kbd_a11y_settings = meta_seat_x11_apply_kbd_a11y_settings;
   seat_class->create_virtual_device = meta_seat_x11_create_virtual_device;
   seat_class->get_supported_virtual_device_types = meta_seat_x11_get_supported_virtual_device_types;
+  seat_class->warp_pointer = meta_seat_x11_warp_pointer;
 
   props[PROP_OPCODE] =
     g_param_spec_int ("opcode",
diff --git a/src/core/window.c b/src/core/window.c
index 53e540484..92811f4b2 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -6869,8 +6869,10 @@ warp_grab_pointer (MetaWindow          *window,
                               &display->grab_anchor_window_pos);
 
   {
-    MetaBackend *backend = meta_get_backend ();
-    meta_backend_warp_pointer (backend, *x, *y);
+    ClutterSeat *seat;
+
+    seat = clutter_backend_get_default_seat (clutter_get_default_backend ());
+    clutter_seat_warp_pointer (seat, *x, *y);
   }
 
   if (meta_x11_error_trap_pop_with_return (display->x11_display) != Success)
diff --git a/src/wayland/meta-pointer-confinement-wayland.c b/src/wayland/meta-pointer-confinement-wayland.c
index 29e5cc3fb..0e2de9c0d 100644
--- a/src/wayland/meta-pointer-confinement-wayland.c
+++ b/src/wayland/meta-pointer-confinement-wayland.c
@@ -643,6 +643,7 @@ meta_pointer_confinement_wayland_maybe_warp (MetaPointerConfinementWayland *self
       GArray *borders;
       float closest_distance_2 = FLT_MAX;
       MetaBorder *closest_border = NULL;
+      ClutterSeat *seat;
       unsigned int i;
       float x;
       float y;
@@ -667,7 +668,9 @@ meta_pointer_confinement_wayland_maybe_warp (MetaPointerConfinementWayland *self
       warp_to_behind_border (closest_border, &sx, &sy);
 
       meta_wayland_surface_get_absolute_coordinates (surface, sx, sy, &x, &y);
-      meta_backend_warp_pointer (meta_get_backend (), (int)x, (int)y);
+
+      seat = clutter_backend_get_default_seat (clutter_get_default_backend ());
+      clutter_seat_warp_pointer (seat, (int)x, (int)y);
     }
 
   cairo_region_destroy (region);
diff --git a/src/wayland/meta-wayland-pointer-constraints.c b/src/wayland/meta-wayland-pointer-constraints.c
index 837779555..320126e69 100644
--- a/src/wayland/meta-wayland-pointer-constraints.c
+++ b/src/wayland/meta-wayland-pointer-constraints.c
@@ -925,7 +925,12 @@ locked_pointer_destroy (struct wl_client   *client,
   wl_resource_destroy (resource);
 
   if (warp_pointer)
-    meta_backend_warp_pointer (meta_get_backend (), warp_x, warp_y);
+    {
+      ClutterSeat *seat;
+
+      seat = clutter_backend_get_default_seat (clutter_get_default_backend ());
+      clutter_seat_warp_pointer (seat, warp_x, warp_y);
+    }
 }
 
 static void


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