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: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1623>
This commit is contained in:
Carlos Garnacho 2020-12-08 13:46:26 +01:00 committed by Marge Bot
parent 0842ac936f
commit e21929be82
4 changed files with 27 additions and 55 deletions

View File

@ -607,21 +607,6 @@ clutter_seat_get_supported_virtual_device_types (ClutterSeat *seat)
return seat_class->get_supported_virtual_device_types (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 gboolean
clutter_seat_handle_event_post (ClutterSeat *seat, clutter_seat_handle_event_post (ClutterSeat *seat,
const ClutterEvent *event) const ClutterEvent *event)

View File

@ -84,10 +84,6 @@ struct _ClutterSeatClass
ClutterKeymap * (* get_keymap) (ClutterSeat *seat); ClutterKeymap * (* get_keymap) (ClutterSeat *seat);
void (* compress_motion) (ClutterSeat *seat,
ClutterEvent *event,
const ClutterEvent *to_discard);
gboolean (* handle_event_post) (ClutterSeat *seat, gboolean (* handle_event_post) (ClutterSeat *seat,
const ClutterEvent *event); const ClutterEvent *event);
@ -151,10 +147,6 @@ ClutterVirtualInputDevice *clutter_seat_create_virtual_device (ClutterSeat
CLUTTER_EXPORT CLUTTER_EXPORT
ClutterVirtualDeviceType clutter_seat_get_supported_virtual_device_types (ClutterSeat *seat); 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 CLUTTER_EXPORT
void clutter_seat_warp_pointer (ClutterSeat *seat, void clutter_seat_warp_pointer (ClutterSeat *seat,
int x, int x,

View File

@ -687,6 +687,32 @@ _clutter_stage_has_queued_events (ClutterStage *stage)
return priv->event_queue->length > 0; 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 void
_clutter_stage_process_queued_events (ClutterStage *stage) _clutter_stage_process_queued_events (ClutterStage *stage)
{ {
@ -754,11 +780,7 @@ _clutter_stage_process_queued_events (ClutterStage *stage)
(int) event->motion.y); (int) event->motion.y);
if (next_event->type == CLUTTER_MOTION) if (next_event->type == CLUTTER_MOTION)
{ clutter_stage_compress_motion (stage, next_event, event);
ClutterSeat *seat = clutter_input_device_get_seat (device);
clutter_seat_compress_motion (seat, next_event, event);
}
goto next_event; goto next_event;
} }

View File

@ -341,32 +341,6 @@ meta_seat_native_get_supported_virtual_device_types (ClutterSeat *seat)
CLUTTER_VIRTUAL_DEVICE_TYPE_TOUCHSCREEN); 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 static void
meta_seat_native_warp_pointer (ClutterSeat *seat, meta_seat_native_warp_pointer (ClutterSeat *seat,
int x, int x,
@ -408,7 +382,6 @@ meta_seat_native_class_init (MetaSeatNativeClass *klass)
seat_class->get_keymap = meta_seat_native_get_keymap; seat_class->get_keymap = meta_seat_native_get_keymap;
seat_class->create_virtual_device = meta_seat_native_create_virtual_device; 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->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->warp_pointer = meta_seat_native_warp_pointer;
seat_class->handle_event_post = meta_seat_native_handle_event_post; seat_class->handle_event_post = meta_seat_native_handle_event_post;
seat_class->query_state = meta_seat_native_query_state; seat_class->query_state = meta_seat_native_query_state;