compositor: fix wp_viewport.set_source errors

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>
This commit is contained in:
Pekka Paalanen 2016-04-26 14:42:11 +03:00
parent bb32ccc045
commit 201769a756

View 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;
}