backends/native: Shuffle static constrain functions up

No functional changes, this just moves two functions up to make the
follow-up patch more obvious.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3410>
This commit is contained in:
Peter Hutterer 2023-11-22 10:55:10 +10:00 committed by Marge Bot
parent e7f91fad9d
commit d575138cce

View File

@ -508,6 +508,72 @@ meta_seat_impl_notify_key_in_impl (MetaSeatImpl *seat_impl,
}
}
static void
constrain_to_barriers (MetaSeatImpl *seat_impl,
ClutterInputDevice *device,
uint32_t time,
float *new_x,
float *new_y)
{
meta_barrier_manager_native_process_in_impl (seat_impl->barrier_manager,
device,
time,
new_x, new_y);
}
/*
* The pointer constrain code is mostly a rip-off of the XRandR code from Xorg.
* (from xserver/randr/rrcrtc.c, RRConstrainCursorHarder)
*
* Copyright © 2006 Keith Packard
* Copyright 2010 Red Hat, Inc
*
*/
static void
constrain_all_screen_monitors (ClutterInputDevice *device,
MetaViewportInfo *viewports,
float *x,
float *y)
{
float cx, cy;
int i, n_views;
meta_input_device_native_get_coords_in_impl (META_INPUT_DEVICE_NATIVE (device),
&cx, &cy);
/* if we're trying to escape, clamp to the CRTC we're coming from */
n_views = meta_viewport_info_get_num_views (viewports);
for (i = 0; i < n_views; i++)
{
int left, right, top, bottom;
MtkRectangle rect;
meta_viewport_info_get_view_info (viewports, i, &rect, NULL);
left = rect.x;
right = left + rect.width;
top = rect.y;
bottom = top + rect.height;
if ((cx >= left) && (cx < right) && (cy >= top) && (cy < bottom))
{
if (*x < left)
*x = left;
if (*x >= right)
*x = right - 1;
if (*y < top)
*y = top;
if (*y >= bottom)
*y = bottom - 1;
return;
}
}
}
static void
constrain_coordinates (MetaSeatImpl *seat_impl,
ClutterInputDevice *input_device,
@ -1096,72 +1162,6 @@ meta_seat_impl_notify_touch_event_in_impl (MetaSeatImpl *seat_impl,
queue_event (seat_impl, event);
}
static void
constrain_to_barriers (MetaSeatImpl *seat_impl,
ClutterInputDevice *device,
uint32_t time,
float *new_x,
float *new_y)
{
meta_barrier_manager_native_process_in_impl (seat_impl->barrier_manager,
device,
time,
new_x, new_y);
}
/*
* The pointer constrain code is mostly a rip-off of the XRandR code from Xorg.
* (from xserver/randr/rrcrtc.c, RRConstrainCursorHarder)
*
* Copyright © 2006 Keith Packard
* Copyright 2010 Red Hat, Inc
*
*/
static void
constrain_all_screen_monitors (ClutterInputDevice *device,
MetaViewportInfo *viewports,
float *x,
float *y)
{
float cx, cy;
int i, n_views;
meta_input_device_native_get_coords_in_impl (META_INPUT_DEVICE_NATIVE (device),
&cx, &cy);
/* if we're trying to escape, clamp to the CRTC we're coming from */
n_views = meta_viewport_info_get_num_views (viewports);
for (i = 0; i < n_views; i++)
{
int left, right, top, bottom;
MtkRectangle rect;
meta_viewport_info_get_view_info (viewports, i, &rect, NULL);
left = rect.x;
right = left + rect.width;
top = rect.y;
bottom = top + rect.height;
if ((cx >= left) && (cx < right) && (cy >= top) && (cy < bottom))
{
if (*x < left)
*x = left;
if (*x >= right)
*x = right - 1;
if (*y < top)
*y = top;
if (*y >= bottom)
*y = bottom - 1;
return;
}
}
}
void
meta_seat_impl_constrain_pointer (MetaSeatImpl *seat_impl,
ClutterInputDevice *core_pointer,