compositor: Factor out check if a view takes input for a point

Make this into its own function so we can use it for sanity checks later.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
This commit is contained in:
Derek Foreman 2022-10-28 12:34:15 -05:00 committed by Pekka Paalanen
parent 266e2e1d48
commit e2e0a73335
2 changed files with 20 additions and 7 deletions

View File

@ -1925,6 +1925,21 @@ weston_compositor_get_time(struct timespec *time)
clock_gettime(CLOCK_REALTIME, time);
}
bool
weston_view_takes_input_at_point(struct weston_view *view, int x, int y)
{
if (!pixman_region32_contains_point(&view->surface->input,
x, y, NULL))
return false;
if (view->geometry.scissor_enabled &&
!pixman_region32_contains_point(&view->geometry.scissor,
x, y, NULL))
return false;
return true;
}
/** weston_compositor_pick_view
* \ingroup compositor
*/
@ -1949,13 +1964,7 @@ weston_compositor_pick_view(struct weston_compositor *compositor,
view_ix = wl_fixed_to_int(view_x);
view_iy = wl_fixed_to_int(view_y);
if (!pixman_region32_contains_point(&view->surface->input,
view_ix, view_iy, NULL))
continue;
if (view->geometry.scissor_enabled &&
!pixman_region32_contains_point(&view->geometry.scissor,
view_ix, view_iy, NULL))
if (!weston_view_takes_input_at_point(view, view_ix, view_iy))
continue;
*vx = view_x;

View File

@ -360,6 +360,10 @@ weston_view_has_valid_buffer(struct weston_view *ev);
bool
weston_view_matches_output_entirely(struct weston_view *ev,
struct weston_output *output);
bool
weston_view_takes_input_at_point(struct weston_view *view, int x, int y);
void
weston_view_move_to_plane(struct weston_view *view,
struct weston_plane *plane);