[mutter/wip/carlosg/clutter-seat: 12/14] clutter: Move motion compression handling to ClutterSeat



commit 4bc5f3c7f54aaf6c02d1e187147d4c6b0c319302
Author: Carlos Garnacho <carlosg gnome org>
Date:   Wed Oct 2 16:41:15 2019 +0200

    clutter: Move motion compression handling to ClutterSeat

 clutter/clutter/clutter-device-manager-private.h |  4 ----
 clutter/clutter/clutter-device-manager.c         | 17 ----------------
 clutter/clutter/clutter-device-manager.h         |  3 ---
 clutter/clutter/clutter-seat.c                   | 16 +++++++++++++++
 clutter/clutter/clutter-seat.h                   |  8 ++++++++
 clutter/clutter/clutter-stage.c                  |  6 ++----
 src/backends/native/meta-device-manager-native.c | 26 ------------------------
 src/backends/native/meta-seat-native.c           | 26 ++++++++++++++++++++++++
 8 files changed, 52 insertions(+), 54 deletions(-)
---
diff --git a/clutter/clutter/clutter-device-manager-private.h 
b/clutter/clutter/clutter-device-manager-private.h
index 918381c55..f072f93f0 100644
--- a/clutter/clutter/clutter-device-manager-private.h
+++ b/clutter/clutter/clutter-device-manager-private.h
@@ -208,10 +208,6 @@ void            _clutter_device_manager_select_stage_events     (ClutterDeviceMa
                                                                  ClutterStage         *stage);
 ClutterBackend *_clutter_device_manager_get_backend             (ClutterDeviceManager *device_manager);
 
-void            _clutter_device_manager_compress_motion         (ClutterDeviceManager *device_manger,
-                                                                 ClutterEvent         *event,
-                                                                 const ClutterEvent   *to_discard);
-
 /* input device */
 CLUTTER_EXPORT
 gboolean        _clutter_input_device_has_sequence              (ClutterInputDevice   *device,
diff --git a/clutter/clutter/clutter-device-manager.c b/clutter/clutter/clutter-device-manager.c
index 4efd2a803..cbf9f53ab 100644
--- a/clutter/clutter/clutter-device-manager.c
+++ b/clutter/clutter/clutter-device-manager.c
@@ -437,20 +437,3 @@ _clutter_device_manager_get_backend (ClutterDeviceManager *manager)
 
   return priv->backend;
 }
-
-void
-_clutter_device_manager_compress_motion (ClutterDeviceManager *device_manager,
-                                         ClutterEvent         *event,
-                                         const ClutterEvent   *to_discard)
-{
-  ClutterDeviceManagerClass *manager_class;
-
-  g_return_if_fail (CLUTTER_IS_DEVICE_MANAGER (device_manager));
-
-
-  manager_class = CLUTTER_DEVICE_MANAGER_GET_CLASS (device_manager);
-  if (!manager_class->compress_motion)
-    return;
-
-  manager_class->compress_motion (device_manager, event, to_discard);
-}
diff --git a/clutter/clutter/clutter-device-manager.h b/clutter/clutter/clutter-device-manager.h
index 902db3bc2..8ef3ed5f8 100644
--- a/clutter/clutter/clutter-device-manager.h
+++ b/clutter/clutter/clutter-device-manager.h
@@ -64,9 +64,6 @@ struct _ClutterDeviceManagerClass
                                            ClutterInputDevice     *device);
   void                (* select_stage_events) (ClutterDeviceManager *manager,
                                                ClutterStage       *stage);
-  void                (* compress_motion) (ClutterDeviceManager *device_manger,
-                                           ClutterEvent         *event,
-                                           const ClutterEvent   *to_discard);
 
   /* padding */
   gpointer _padding[4];
diff --git a/clutter/clutter/clutter-seat.c b/clutter/clutter/clutter-seat.c
index d2f24d23d..dbdc08a07 100644
--- a/clutter/clutter/clutter-seat.c
+++ b/clutter/clutter/clutter-seat.c
@@ -540,3 +540,19 @@ clutter_seat_get_supported_virtual_device_types (ClutterSeat *seat)
   seat_class = CLUTTER_SEAT_GET_CLASS (seat);
   return seat_class->get_supported_virtual_device_types (seat);
 }
+
+void
+clutter_seat_compress_motion (ClutterSeat        *seat,
+                              ClutterEvent       *event,
+                              const ClutterEvent *to_discard)
+{
+  ClutterSeatClass *seat_class;
+
+  g_return_if_fail (CLUTTER_IS_SEAT (seat));
+
+  seat_class = CLUTTER_SEAT_GET_CLASS (seat);
+  if (!seat_class->compress_motion)
+    return;
+
+  seat_class->compress_motion (seat, event, to_discard);
+}
diff --git a/clutter/clutter/clutter-seat.h b/clutter/clutter/clutter-seat.h
index edb860c1c..cdb16d9c1 100644
--- a/clutter/clutter/clutter-seat.h
+++ b/clutter/clutter/clutter-seat.h
@@ -103,6 +103,10 @@ struct _ClutterSeatClass
 
   ClutterKeymap * (* get_keymap) (ClutterSeat *seat);
 
+  void (* compress_motion) (ClutterSeat        *seat,
+                            ClutterEvent       *event,
+                            const ClutterEvent *to_discard);
+
   /* Event platform data */
   void (* copy_event_data) (ClutterSeat        *seat,
                             const ClutterEvent *src,
@@ -160,4 +164,8 @@ ClutterVirtualInputDevice *clutter_seat_create_virtual_device (ClutterSeat
 CLUTTER_EXPORT
 ClutterVirtualDeviceType clutter_seat_get_supported_virtual_device_types (ClutterSeat *seat);
 
+void clutter_seat_compress_motion (ClutterSeat        *seat,
+                                   ClutterEvent       *event,
+                                   const ClutterEvent *to_discard);
+
 #endif /* CLUTTER_SEAT_H */
diff --git a/clutter/clutter/clutter-stage.c b/clutter/clutter/clutter-stage.c
index 245cb8997..b2fc9e2cf 100644
--- a/clutter/clutter/clutter-stage.c
+++ b/clutter/clutter/clutter-stage.c
@@ -1228,11 +1228,9 @@ _clutter_stage_process_queued_events (ClutterStage *stage)
 
               if (next_event->type == CLUTTER_MOTION)
                 {
-                  ClutterDeviceManager *device_manager =
-                    clutter_device_manager_get_default ();
+                  ClutterSeat *seat = clutter_input_device_get_seat (device);
 
-                  _clutter_device_manager_compress_motion (device_manager,
-                                                           next_event, event);
+                  clutter_seat_compress_motion (seat, next_event, event);
                 }
 
               goto next_event;
diff --git a/src/backends/native/meta-device-manager-native.c 
b/src/backends/native/meta-device-manager-native.c
index 40681b1f4..b08a06a4b 100644
--- a/src/backends/native/meta-device-manager-native.c
+++ b/src/backends/native/meta-device-manager-native.c
@@ -127,31 +127,6 @@ meta_device_manager_native_get_device (ClutterDeviceManager *manager,
   return NULL;
 }
 
-static void
-meta_device_manager_native_compress_motion (ClutterDeviceManager *device_manger,
-                                            ClutterEvent         *event,
-                                            const ClutterEvent   *to_discard)
-{
-  double dx, dy;
-  double dx_unaccel, dy_unaccel;
-  double dst_dx = 0.0, dst_dy = 0.0;
-  double dst_dx_unaccel = 0.0, dst_dy_unaccel = 0.0;
-
-  if (!meta_event_native_get_relative_motion (to_discard,
-                                              &dx, &dy,
-                                              &dx_unaccel, &dy_unaccel))
-    return;
-
-  meta_event_native_get_relative_motion (event,
-                                         &dst_dx, &dst_dy,
-                                         &dst_dx_unaccel, &dst_dy_unaccel);
-  meta_event_native_set_relative_motion (event,
-                                         dx + dst_dx,
-                                         dy + dst_dy,
-                                         dx_unaccel + dst_dx_unaccel,
-                                         dy_unaccel + dst_dy_unaccel);
-}
-
 /*
  * GObject implementation
  */
@@ -166,7 +141,6 @@ meta_device_manager_native_class_init (MetaDeviceManagerNativeClass *klass)
   manager_class->get_devices = meta_device_manager_native_get_devices;
   manager_class->get_core_device = meta_device_manager_native_get_core_device;
   manager_class->get_device = meta_device_manager_native_get_device;
-  manager_class->compress_motion = meta_device_manager_native_compress_motion;
 }
 
 static void
diff --git a/src/backends/native/meta-seat-native.c b/src/backends/native/meta-seat-native.c
index 00a75dd90..db769045a 100644
--- a/src/backends/native/meta-seat-native.c
+++ b/src/backends/native/meta-seat-native.c
@@ -2589,6 +2589,31 @@ meta_seat_native_get_supported_virtual_device_types (ClutterSeat *seat)
           CLUTTER_VIRTUAL_DEVICE_TYPE_TOUCHSCREEN);
 }
 
+static void
+meta_seat_native_compress_motion (ClutterSeat        *seat,
+                                  ClutterEvent       *event,
+                                  const ClutterEvent *to_discard)
+{
+  double dx, dy;
+  double dx_unaccel, dy_unaccel;
+  double dst_dx = 0.0, dst_dy = 0.0;
+  double dst_dx_unaccel = 0.0, dst_dy_unaccel = 0.0;
+
+  if (!meta_event_native_get_relative_motion (to_discard,
+                                              &dx, &dy,
+                                              &dx_unaccel, &dy_unaccel))
+    return;
+
+  meta_event_native_get_relative_motion (event,
+                                         &dst_dx, &dst_dy,
+                                         &dst_dx_unaccel, &dst_dy_unaccel);
+  meta_event_native_set_relative_motion (event,
+                                         dx + dst_dx,
+                                         dy + dst_dy,
+                                         dx_unaccel + dst_dx_unaccel,
+                                         dy_unaccel + dst_dy_unaccel);
+}
+
 static void
 meta_seat_native_class_init (MetaSeatNativeClass *klass)
 {
@@ -2611,6 +2636,7 @@ meta_seat_native_class_init (MetaSeatNativeClass *klass)
   seat_class->apply_kbd_a11y_settings = meta_seat_native_apply_kbd_a11y_settings;
   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;
 
   props[PROP_SEAT_ID] =
     g_param_spec_string ("seat-id",


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