clutter/event: Set the constrained relative motion too

When a relative pointer motion gets constrained (e.g. a monitor edge or
barrier), save the constrained relative motion delta too.

This will later be used to send the remaining motion delta to input
capture clients.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2628>
This commit is contained in:
Jonas Ådahl 2022-04-28 15:53:16 +02:00 committed by Carlos Garnacho
parent a170f2a82b
commit 38d1666049
2 changed files with 25 additions and 8 deletions

View File

@ -280,6 +280,8 @@ struct _ClutterMotionEvent
double dy; double dy;
double dx_unaccel; double dx_unaccel;
double dy_unaccel; double dy_unaccel;
double dx_constrained;
double dy_constrained;
}; };
/** /**

View File

@ -903,8 +903,9 @@ meta_seat_impl_notify_relative_motion_in_impl (MetaSeatImpl *seat_impl,
float dx_unaccel, float dx_unaccel,
float dy_unaccel) float dy_unaccel)
{ {
float new_x, new_y;
ClutterEvent *event; ClutterEvent *event;
float old_x, old_y;
double dx_constrained, dy_constrained;
meta_seat_impl_filter_relative_motion (seat_impl, meta_seat_impl_filter_relative_motion (seat_impl,
input_device, input_device,
@ -913,16 +914,23 @@ meta_seat_impl_notify_relative_motion_in_impl (MetaSeatImpl *seat_impl,
&dx, &dx,
&dy); &dy);
new_x = seat_impl->pointer_x + dx; old_x = seat_impl->pointer_x;
new_y = seat_impl->pointer_y + dy; old_y = seat_impl->pointer_y;
event = new_absolute_motion_event (seat_impl, input_device, event = new_absolute_motion_event (seat_impl, input_device,
time_us, new_x, new_y, NULL); time_us,
old_x + dx,
old_y + dy,
NULL);
dx_constrained = event->motion.x - old_x;
dy_constrained = event->motion.y - old_y;
event->motion.flags |= CLUTTER_EVENT_FLAG_RELATIVE_MOTION; event->motion.flags |= CLUTTER_EVENT_FLAG_RELATIVE_MOTION;
event->motion.dx = dx; event->motion.dx = dx;
event->motion.dy = dy; event->motion.dy = dy;
event->motion.dx_unaccel = dx_unaccel; event->motion.dx_unaccel = dx_unaccel;
event->motion.dy_unaccel = dy_unaccel; event->motion.dy_unaccel = dy_unaccel;
event->motion.dx_constrained = dx_constrained;
event->motion.dy_constrained = dy_constrained;
queue_event (seat_impl, event); queue_event (seat_impl, event);
} }
@ -1595,7 +1603,9 @@ notify_relative_tool_motion_in_impl (ClutterInputDevice *input_device,
MetaInputDeviceNative *device_native; MetaInputDeviceNative *device_native;
ClutterEvent *event; ClutterEvent *event;
MetaSeatImpl *seat_impl; MetaSeatImpl *seat_impl;
float x, y; float old_x, old_y;
double dx_constrained, dy_constrained;
device_native = META_INPUT_DEVICE_NATIVE (input_device); device_native = META_INPUT_DEVICE_NATIVE (input_device);
seat_impl = seat_impl_from_device (input_device); seat_impl = seat_impl_from_device (input_device);
@ -1607,15 +1617,20 @@ notify_relative_tool_motion_in_impl (ClutterInputDevice *input_device,
&dx, &dx,
&dy); &dy);
x = device_native->pointer_x + dx; old_x = device_native->pointer_x;
y = device_native->pointer_y + dy; old_y = device_native->pointer_y;
event = new_absolute_motion_event (seat_impl, input_device, time_us, event = new_absolute_motion_event (seat_impl, input_device, time_us,
x, y, axes); old_x + dx, old_y + dy, axes);
dx_constrained = event->motion.x - old_x;
dy_constrained = event->motion.y - old_y;
event->motion.flags |= CLUTTER_EVENT_FLAG_RELATIVE_MOTION; event->motion.flags |= CLUTTER_EVENT_FLAG_RELATIVE_MOTION;
event->motion.dx = dx; event->motion.dx = dx;
event->motion.dy = dy; event->motion.dy = dy;
event->motion.dx_constrained = dx_constrained;
event->motion.dy_constrained = dy_constrained;
queue_event (seat_impl, event); queue_event (seat_impl, event);
} }