compositor: fix wp_viewport.set_source errors
authorPekka Paalanen <pekka.paalanen@collabora.co.uk>
Tue, 26 Apr 2016 11:42:11 +0000 (14:42 +0300)
committerPekka Paalanen <pekka.paalanen@collabora.co.uk>
Thu, 9 Jun 2016 08:17:16 +0000 (11:17 +0300)
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@collabora.co.uk>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
src/compositor.c

index 6fbda9908d7318aa02d2764db946fee42b01a1cc..37d94ec91f0e5a6b25d0405fde281dfc9377bcb0 100644 (file)
@@ -4366,22 +4366,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;
        }