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



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

    clutter: Move motion compression handling to ClutterSeat
    
    Another responsibility taken away from ClutterDeviceManager
    
    https://gitlab.gnome.org/GNOME/mutter/merge_requests/852

 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 |  1 -
 src/backends/native/meta-seat-native.c           | 26 ++++++++++++++++++++++++
 8 files changed, 52 insertions(+), 29 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 df8a8e9d1..884e44eac 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 7fee59fac..916e61d57 100644
--- a/clutter/clutter/clutter-seat.h
+++ b/clutter/clutter/clutter-seat.h
@@ -102,6 +102,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,
@@ -158,4 +162,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 4b051afc3..77cd34843 100644
--- a/clutter/clutter/clutter-stage.c
+++ b/clutter/clutter/clutter-stage.c
@@ -1274,11 +1274,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 fa0b8feb3..15d291ea1 100644
--- a/src/backends/native/meta-device-manager-native.c
+++ b/src/backends/native/meta-device-manager-native.c
@@ -188,7 +188,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 34014bdad..d7dea5fa7 100644
--- a/src/backends/native/meta-seat-native.c
+++ b/src/backends/native/meta-seat-native.c
@@ -2599,6 +2599,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)
 {
@@ -2621,6 +2646,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]