[PATCH weston v3 16/17] compositor: fix wp_viewport.set_source errors

Pekka Paalanen ppaalanen at gmail.com
Tue Apr 26 12:51:08 UTC 2016


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

The revised wp_viewport spec requires that unset has to have all of x, y,
width and height -1 to be recognized.

Check for negative x and y and raise the required error. The error event
now mentions the wl_surface, too.

Signed-off-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
---
 src/compositor.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/src/compositor.c b/src/compositor.c
index 0c2de04..8349113 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -4498,22 +4498,29 @@ viewport_set_source(struct wl_client *client,
 	}
 
 	assert(surface->viewport_resource == resource);
+	assert(surface->resource);
 
 	if (src_width == wl_fixed_from_int(-1) &&
-	    src_height == wl_fixed_from_int(-1)) {
-		/* unset source size */
+	    src_height == wl_fixed_from_int(-1) &&
+	    src_x == wl_fixed_from_int(-1) &&
+	    src_y == wl_fixed_from_int(-1)) {
+		/* unset source rect */
 		surface->pending.buffer_viewport.buffer.src_width =
 			wl_fixed_from_int(-1);
 		surface->pending.buffer_viewport.changed = 1;
 		return;
 	}
 
-	if (src_width <= 0 || src_height <= 0) {
+	if (src_width <= 0 || src_height <= 0 || src_x < 0 || src_y < 0) {
 		wl_resource_post_error(resource,
 			WP_VIEWPORT_ERROR_BAD_VALUE,
-			"source size must be positive (%fx%f)",
+			"wl_surface@%d viewport source "
+			"w=%f <= 0, h=%f <= 0, x=%f < 0, or y=%f < 0",
+			wl_resource_get_id(surface->resource),
 			wl_fixed_to_double(src_width),
-			wl_fixed_to_double(src_height));
+			wl_fixed_to_double(src_height),
+			wl_fixed_to_double(src_x),
+			wl_fixed_to_double(src_y));
 		return;
 	}
 
-- 
2.7.3



More information about the wayland-devel mailing list