mirror of
https://github.com/brl/mutter.git
synced 2024-12-26 21:02:14 +00:00
backends/native: If the tablet tool is relative, constrain it normally
If we're moving our tool like a relative pointer, constrain to our viewports, if any. This fixes the cursor moving off the screen in relative mode. Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3168 Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3410>
This commit is contained in:
parent
d575138cce
commit
f76952e83f
@ -574,6 +574,26 @@ constrain_all_screen_monitors (ClutterInputDevice *device,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
constrain_to_viewports (MetaSeatImpl *seat_impl,
|
||||
ClutterInputDevice *device,
|
||||
uint64_t time_us,
|
||||
float *x_inout,
|
||||
float *y_inout)
|
||||
{
|
||||
if (seat_impl->viewports)
|
||||
{
|
||||
/* if we're moving inside a monitor, we're fine */
|
||||
if (meta_viewport_info_get_view_at (seat_impl->viewports,
|
||||
*x_inout, *y_inout) >= 0)
|
||||
return;
|
||||
|
||||
/* if we're trying to escape, clamp to the CRTC we're coming from */
|
||||
constrain_all_screen_monitors (device, seat_impl->viewports,
|
||||
x_inout, y_inout);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
constrain_coordinates (MetaSeatImpl *seat_impl,
|
||||
ClutterInputDevice *input_device,
|
||||
@ -583,16 +603,31 @@ constrain_coordinates (MetaSeatImpl *seat_impl,
|
||||
float *x_out,
|
||||
float *y_out)
|
||||
{
|
||||
MetaInputDeviceNative *device_evdev = META_INPUT_DEVICE_NATIVE (input_device);
|
||||
|
||||
if (clutter_input_device_get_device_type (input_device) == CLUTTER_TABLET_DEVICE)
|
||||
{
|
||||
/* Viewport may be unset during startup */
|
||||
if (seat_impl->viewports)
|
||||
{
|
||||
meta_input_device_native_translate_coordinates_in_impl (input_device,
|
||||
seat_impl->viewports,
|
||||
&x,
|
||||
&y);
|
||||
}
|
||||
if (device_evdev->mapping_mode == META_INPUT_DEVICE_MAPPING_RELATIVE)
|
||||
{
|
||||
constrain_to_barriers (seat_impl, input_device,
|
||||
us2ms (time_us),
|
||||
&x, &y);
|
||||
constrain_to_viewports (seat_impl,
|
||||
input_device,
|
||||
time_us,
|
||||
&x, &y);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Viewport may be unset during startup */
|
||||
if (seat_impl->viewports)
|
||||
{
|
||||
meta_input_device_native_translate_coordinates_in_impl (input_device,
|
||||
seat_impl->viewports,
|
||||
&x,
|
||||
&y);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1186,17 +1221,7 @@ meta_seat_impl_constrain_pointer (MetaSeatImpl *seat_impl,
|
||||
new_x, new_y);
|
||||
}
|
||||
|
||||
if (seat_impl->viewports)
|
||||
{
|
||||
/* if we're moving inside a monitor, we're fine */
|
||||
if (meta_viewport_info_get_view_at (seat_impl->viewports,
|
||||
*new_x, *new_y) >= 0)
|
||||
return;
|
||||
|
||||
/* if we're trying to escape, clamp to the CRTC we're coming from */
|
||||
constrain_all_screen_monitors (core_pointer, seat_impl->viewports,
|
||||
new_x, new_y);
|
||||
}
|
||||
constrain_to_viewports (seat_impl, core_pointer, time_us, new_x, new_y);
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user