compositor: restructure weston_compositor_pick_view()

Expand weston_compositor_pick_view() so it is easier to read. Use
short-hand variables, that make it easier to add one more test in the
future.

Write the output coordinate pointers only when returning non-NULL.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Nobuhiko Tanibata <NOBUHIKO_TANIBATA@xddp.denso.co.jp>
Tested-by: Nobuhiko Tanibata <NOBUHIKO_TANIBATA@xddp.denso.co.jp>
Reviewed-By: Derek Foreman <derekf@osg.samsung.com>
dev
Pekka Paalanen 10 years ago
parent 6c7a1c7b07
commit fc22a52647
  1. 23
      src/compositor.c

@ -1543,17 +1543,26 @@ weston_compositor_pick_view(struct weston_compositor *compositor,
wl_fixed_t *vx, wl_fixed_t *vy) wl_fixed_t *vx, wl_fixed_t *vy)
{ {
struct weston_view *view; struct weston_view *view;
wl_fixed_t view_x, view_y;
int view_ix, view_iy;
int ix = wl_fixed_to_int(x); int ix = wl_fixed_to_int(x);
int iy = wl_fixed_to_int(y); int iy = wl_fixed_to_int(y);
wl_list_for_each(view, &compositor->view_list, link) { wl_list_for_each(view, &compositor->view_list, link) {
weston_view_from_global_fixed(view, x, y, vx, vy); if (!pixman_region32_contains_point(
if (pixman_region32_contains_point( &view->transform.boundingbox, ix, iy, NULL))
&view->transform.boundingbox, ix, iy, NULL) && continue;
pixman_region32_contains_point(&view->surface->input,
wl_fixed_to_int(*vx), weston_view_from_global_fixed(view, x, y, &view_x, &view_y);
wl_fixed_to_int(*vy), view_ix = wl_fixed_to_int(view_x);
NULL)) view_iy = wl_fixed_to_int(view_y);
if (!pixman_region32_contains_point(&view->surface->input,
view_ix, view_iy, NULL))
continue;
*vx = view_x;
*vy = view_y;
return view; return view;
} }

Loading…
Cancel
Save