[PATCH weston 1/4] compositor: restructure weston_compositor_pick_view()

Pekka Paalanen ppaalanen at gmail.com
Mon Mar 2 07:15:58 PST 2015


From: Pekka Paalanen <pekka.paalanen at collabora.co.uk>

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 at collabora.co.uk>
Reviewed-by: Nobuhiko Tanibata <NOBUHIKO_TANIBATA at xddp.denso.co.jp>
Tested-by: Nobuhiko Tanibata <NOBUHIKO_TANIBATA at xddp.denso.co.jp>
---
 src/compositor.c | 29 +++++++++++++++++++----------
 1 file changed, 19 insertions(+), 10 deletions(-)

diff --git a/src/compositor.c b/src/compositor.c
index 46e3756..269d485 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -1543,18 +1543,27 @@ weston_compositor_pick_view(struct weston_compositor *compositor,
 			    wl_fixed_t *vx, wl_fixed_t *vy)
 {
 	struct weston_view *view;
-        int ix = wl_fixed_to_int(x);
-        int iy = wl_fixed_to_int(y);
+	wl_fixed_t view_x, view_y;
+	int view_ix, view_iy;
+	int ix = wl_fixed_to_int(x);
+	int iy = wl_fixed_to_int(y);
 
 	wl_list_for_each(view, &compositor->view_list, link) {
-		weston_view_from_global_fixed(view, x, y, vx, vy);
-		if (pixman_region32_contains_point(
-			&view->transform.boundingbox, ix, iy, NULL) &&
-		    pixman_region32_contains_point(&view->surface->input,
-						   wl_fixed_to_int(*vx),
-						   wl_fixed_to_int(*vy),
-						   NULL))
-			return view;
+		if (!pixman_region32_contains_point(
+				&view->transform.boundingbox, ix, iy, NULL))
+			continue;
+
+		weston_view_from_global_fixed(view, x, y, &view_x, &view_y);
+		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;
+
+		*vx = view_x;
+		*vy = view_y;
+		return view;
 	}
 
 	return NULL;
-- 
2.0.5



More information about the wayland-devel mailing list