input: Add weston_pointer_clamp function to ensure pointer visible
This refactors the code out from clip_pointer_motion into a function of its own which can then be used elsewhere to clamp the pointer coordinates to the range of the outputs. This change also makes the caller of clip_pointer_motion use this new function.
This commit is contained in:
committed by
Kristian Høgsberg
parent
1d697d7adf
commit
806d8c0b78
@@ -345,6 +345,9 @@ weston_pointer_start_grab(struct weston_pointer *pointer,
|
|||||||
struct weston_pointer_grab *grab);
|
struct weston_pointer_grab *grab);
|
||||||
void
|
void
|
||||||
weston_pointer_end_grab(struct weston_pointer *pointer);
|
weston_pointer_end_grab(struct weston_pointer *pointer);
|
||||||
|
void
|
||||||
|
weston_pointer_clamp(struct weston_pointer *pointer,
|
||||||
|
wl_fixed_t *fx, wl_fixed_t *fy);
|
||||||
|
|
||||||
struct weston_keyboard *
|
struct weston_keyboard *
|
||||||
weston_keyboard_create(void);
|
weston_keyboard_create(void);
|
||||||
|
|||||||
+6
-6
@@ -561,17 +561,17 @@ weston_touch_end_grab(struct weston_touch *touch)
|
|||||||
touch->grab = &touch->default_grab;
|
touch->grab = &touch->default_grab;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
WL_EXPORT void
|
||||||
clip_pointer_motion(struct weston_seat *seat, wl_fixed_t *fx, wl_fixed_t *fy)
|
weston_pointer_clamp(struct weston_pointer *pointer, wl_fixed_t *fx, wl_fixed_t *fy)
|
||||||
{
|
{
|
||||||
struct weston_compositor *ec = seat->compositor;
|
struct weston_compositor *ec = pointer->seat->compositor;
|
||||||
struct weston_output *output, *prev = NULL;
|
struct weston_output *output, *prev = NULL;
|
||||||
int x, y, old_x, old_y, valid = 0;
|
int x, y, old_x, old_y, valid = 0;
|
||||||
|
|
||||||
x = wl_fixed_to_int(*fx);
|
x = wl_fixed_to_int(*fx);
|
||||||
y = wl_fixed_to_int(*fy);
|
y = wl_fixed_to_int(*fy);
|
||||||
old_x = wl_fixed_to_int(seat->pointer->x);
|
old_x = wl_fixed_to_int(pointer->x);
|
||||||
old_y = wl_fixed_to_int(seat->pointer->y);
|
old_y = wl_fixed_to_int(pointer->y);
|
||||||
|
|
||||||
wl_list_for_each(output, &ec->output_list, link) {
|
wl_list_for_each(output, &ec->output_list, link) {
|
||||||
if (pixman_region32_contains_point(&output->region,
|
if (pixman_region32_contains_point(&output->region,
|
||||||
@@ -605,7 +605,7 @@ move_pointer(struct weston_seat *seat, wl_fixed_t x, wl_fixed_t y)
|
|||||||
struct weston_output *output;
|
struct weston_output *output;
|
||||||
int32_t ix, iy;
|
int32_t ix, iy;
|
||||||
|
|
||||||
clip_pointer_motion(seat, &x, &y);
|
weston_pointer_clamp (pointer, &x, &y);
|
||||||
|
|
||||||
pointer->x = x;
|
pointer->x = x;
|
||||||
pointer->y = y;
|
pointer->y = y;
|
||||||
|
|||||||
Reference in New Issue
Block a user