compositor: replace weston_buffer_viewport::viewport_set
Remove the explicit boolean variable, and use illegal width to denote
"not set".
Split the boolean into two, so we can later start having buffer.src_*
and surface.* set or not set independently. This may become useful when
the wl_viewport interface is changed to allow modifying them separately.
At the moment, both buffer.src_width and surface.width conditions are
always in sync.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
diff --git a/src/compositor.c b/src/compositor.c
index 83ec979..82edf35 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -402,7 +402,8 @@
surface->buffer_viewport.buffer.transform = WL_OUTPUT_TRANSFORM_NORMAL;
surface->buffer_viewport.buffer.scale = 1;
- surface->buffer_viewport.buffer.viewport_set = 0;
+ surface->buffer_viewport.buffer.src_width = wl_fixed_from_int(-1);
+ surface->buffer_viewport.surface.width = -1;
surface->pending.buffer_viewport = surface->buffer_viewport;
surface->output = NULL;
surface->pending.newly_attached = 0;
@@ -641,7 +642,8 @@
{
struct weston_buffer_viewport *vp = &surface->buffer_viewport;
- if (vp->buffer.viewport_set) {
+ if (vp->buffer.src_width != wl_fixed_from_int(-1) &&
+ vp->surface.width != -1) {
double a, b;
a = sx / vp->surface.width;
@@ -1204,7 +1206,8 @@
return;
}
- if (vp->buffer.viewport_set) {
+ if (vp->buffer.src_width != wl_fixed_from_int(-1) &&
+ vp->surface.width != -1) {
surface_set_size(surface, vp->surface.width,
vp->surface.height);
return;
@@ -3359,7 +3362,9 @@
wl_resource_get_user_data(resource);
surface->viewport_resource = NULL;
- surface->pending.buffer_viewport.buffer.viewport_set = 0;
+ surface->pending.buffer_viewport.buffer.src_width =
+ wl_fixed_from_int(-1);
+ surface->pending.buffer_viewport.surface.width = -1;
}
static void
@@ -3402,8 +3407,6 @@
return;
}
- surface->pending.buffer_viewport.buffer.viewport_set = 1;
-
surface->pending.buffer_viewport.buffer.src_x = src_x;
surface->pending.buffer_viewport.buffer.src_y = src_y;
surface->pending.buffer_viewport.buffer.src_width = src_width;