clutter: Move motion compression handling to ClutterSeat

Another responsibility taken away from ClutterDeviceManager

https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
This commit is contained in:
Carlos Garnacho 2019-10-02 16:41:15 +02:00
parent efe698f6e1
commit b8c8b59dc8
8 changed files with 52 additions and 29 deletions

View File

@ -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,

View File

@ -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);
}

View File

@ -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];

View File

@ -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);
}

View File

@ -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 */

View File

@ -1248,11 +1248,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;

View File

@ -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

View File

@ -2587,6 +2587,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)
{
@ -2609,6 +2634,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",