libweston: Refactor point in output test

This is arguably a little nicer without calling the pixman functions
directly.

In the future when we have different datatypes for coordinates in different
spaces, this test will only be valid on global coordinates, so this change
is also a precursor to stronger type validation.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
This commit is contained in:
Derek Foreman 2022-08-31 11:48:05 -05:00 committed by Pekka Paalanen
parent 5c352b8f4f
commit bb8ef7d271
4 changed files with 17 additions and 11 deletions

View File

@ -3836,7 +3836,7 @@ weston_view_set_initial_position(struct weston_view *view,
}
wl_list_for_each(output, &compositor->output_list, link) {
if (pixman_region32_contains_point(&output->region, ix, iy, NULL)) {
if (weston_output_contains_point(output, ix, iy)) {
target_output = output;
break;
}
@ -4251,8 +4251,7 @@ shell_reposition_view_on_output_change(struct weston_view *view)
* otherwise, move it to the first output. */
visible = 0;
wl_list_for_each(output, &ec->output_list, link) {
if (pixman_region32_contains_point(&output->region,
x, y, NULL)) {
if (weston_output_contains_point(output, x, y)) {
visible = 1;
break;
}

View File

@ -2311,6 +2311,10 @@ void
weston_output_allow_protection(struct weston_output *output,
bool allow_protection);
bool
weston_output_contains_point(struct weston_output *output,
int32_t x, int32_t y);
int
weston_compositor_enable_touch_calibrator(struct weston_compositor *compositor,
weston_touch_calibration_save_func save);

View File

@ -201,6 +201,13 @@ weston_mode_switch_send_events(struct weston_head *head,
}
}
WL_EXPORT bool
weston_output_contains_point(struct weston_output *output,
int32_t x, int32_t y)
{
return pixman_region32_contains_point(&output->region, x, y, NULL);
}
static void
weston_mode_switch_finish(struct weston_output *output,
int mode_changed, int scale_changed)
@ -234,8 +241,7 @@ weston_mode_switch_finish(struct weston_output *output,
if (!pixman_region32_contains_point(&old_output_region,
x, y, NULL) ||
pixman_region32_contains_point(&output->region,
x, y, NULL))
weston_output_contains_point(output, x, y))
continue;
if (x >= output->x + output->width)

View File

@ -1688,11 +1688,9 @@ weston_pointer_clamp(struct weston_pointer *pointer, wl_fixed_t *fx, wl_fixed_t
wl_list_for_each(output, &ec->output_list, link) {
if (pointer->seat->output && pointer->seat->output != output)
continue;
if (pixman_region32_contains_point(&output->region,
x, y, NULL))
if (weston_output_contains_point(output, x, y))
valid = 1;
if (pixman_region32_contains_point(&output->region,
old_x, old_y, NULL))
if (weston_output_contains_point(output, old_x, old_y))
prev = output;
}
@ -1757,8 +1755,7 @@ weston_pointer_handle_output_destroy(struct wl_listener *listener, void *data)
y = wl_fixed_to_int(pointer->y);
wl_list_for_each(output, &ec->output_list, link) {
if (pixman_region32_contains_point(&output->region,
x, y, NULL))
if (weston_output_contains_point(output, x, y))
return;
/* Aproximante the distance from the pointer to the center of