From e21929be82aced9afbfdb681b74148ed22dda59c Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 8 Dec 2020 13:46:26 +0100 Subject: [PATCH] clutter: Do not poke backend code for motion compression We now have all info available in ClutterEvent, use it and stop poking backend internals. Part-of: --- clutter/clutter/clutter-seat.c | 15 ------------ clutter/clutter/clutter-seat.h | 8 ------- clutter/clutter/clutter-stage.c | 32 ++++++++++++++++++++++---- src/backends/native/meta-seat-native.c | 27 ---------------------- 4 files changed, 27 insertions(+), 55 deletions(-) diff --git a/clutter/clutter/clutter-seat.c b/clutter/clutter/clutter-seat.c index f4309787c..1908fda12 100644 --- a/clutter/clutter/clutter-seat.c +++ b/clutter/clutter/clutter-seat.c @@ -607,21 +607,6 @@ clutter_seat_get_supported_virtual_device_types (ClutterSeat *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) - seat_class->compress_motion (seat, event, to_discard); -} - gboolean clutter_seat_handle_event_post (ClutterSeat *seat, const ClutterEvent *event) diff --git a/clutter/clutter/clutter-seat.h b/clutter/clutter/clutter-seat.h index 135789588..5c5dfe6eb 100644 --- a/clutter/clutter/clutter-seat.h +++ b/clutter/clutter/clutter-seat.h @@ -84,10 +84,6 @@ struct _ClutterSeatClass ClutterKeymap * (* get_keymap) (ClutterSeat *seat); - void (* compress_motion) (ClutterSeat *seat, - ClutterEvent *event, - const ClutterEvent *to_discard); - gboolean (* handle_event_post) (ClutterSeat *seat, const ClutterEvent *event); @@ -151,10 +147,6 @@ 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); - CLUTTER_EXPORT void clutter_seat_warp_pointer (ClutterSeat *seat, int x, diff --git a/clutter/clutter/clutter-stage.c b/clutter/clutter/clutter-stage.c index af6c413ba..fd12c0381 100644 --- a/clutter/clutter/clutter-stage.c +++ b/clutter/clutter/clutter-stage.c @@ -687,6 +687,32 @@ _clutter_stage_has_queued_events (ClutterStage *stage) return priv->event_queue->length > 0; } +static void +clutter_stage_compress_motion (ClutterStage *stage, + 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 (!clutter_event_get_relative_motion (to_discard, + &dx, &dy, + &dx_unaccel, &dy_unaccel)) + return; + + clutter_event_get_relative_motion (event, + &dst_dx, &dst_dy, + &dst_dx_unaccel, &dst_dy_unaccel); + + event->motion.flags |= CLUTTER_EVENT_FLAG_RELATIVE_MOTION; + event->motion.dx = dx + dst_dx; + event->motion.dy = dy + dst_dy; + event->motion.dx_unaccel = dx_unaccel + dst_dx_unaccel; + event->motion.dy_unaccel = dy_unaccel + dst_dy_unaccel; +} + void _clutter_stage_process_queued_events (ClutterStage *stage) { @@ -754,11 +780,7 @@ _clutter_stage_process_queued_events (ClutterStage *stage) (int) event->motion.y); if (next_event->type == CLUTTER_MOTION) - { - ClutterSeat *seat = clutter_input_device_get_seat (device); - - clutter_seat_compress_motion (seat, next_event, event); - } + clutter_stage_compress_motion (stage, next_event, event); goto next_event; } diff --git a/src/backends/native/meta-seat-native.c b/src/backends/native/meta-seat-native.c index 150fe90df..9b931932b 100644 --- a/src/backends/native/meta-seat-native.c +++ b/src/backends/native/meta-seat-native.c @@ -341,32 +341,6 @@ 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 (!clutter_event_get_relative_motion (to_discard, - &dx, &dy, - &dx_unaccel, &dy_unaccel)) - return; - - clutter_event_get_relative_motion (event, - &dst_dx, &dst_dy, - &dst_dx_unaccel, &dst_dy_unaccel); - - event->motion.flags |= CLUTTER_EVENT_FLAG_RELATIVE_MOTION; - event->motion.dx = dx + dst_dx; - event->motion.dy = dy + dst_dy; - event->motion.dx_unaccel = dx_unaccel + dst_dx_unaccel; - event->motion.dy_unaccel = dy_unaccel + dst_dy_unaccel; -} - static void meta_seat_native_warp_pointer (ClutterSeat *seat, int x, @@ -408,7 +382,6 @@ meta_seat_native_class_init (MetaSeatNativeClass *klass) seat_class->get_keymap = meta_seat_native_get_keymap; 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; seat_class->handle_event_post = meta_seat_native_handle_event_post; seat_class->query_state = meta_seat_native_query_state;