aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Kenny Levinsen <kl@kl.wtf>2021-04-25 23:25:23 +0200
committerLibravatar Simon Ser <contact@emersion.fr>2021-06-24 18:21:29 +0200
commit2660c0c1bc002be43b5c8531d514ba06c572b287 (patch)
tree52ae7e855ba9c651cac114914be1368b1d9b2114
parentRemove usage of surface->sx|sy (diff)
downloadsway-2660c0c1bc002be43b5c8531d514ba06c572b287.tar.gz
sway-2660c0c1bc002be43b5c8531d514ba06c572b287.tar.zst
sway-2660c0c1bc002be43b5c8531d514ba06c572b287.zip
desktop/render: Pass explicit clip box to render
render_surface_iterator previously deduced the clip box from an optional container passed with render data. This causes problems when offsets in view geometry need to be compensated for in the clip dimensions. Instead, prepare the clip box in render_view_toplevels where the offsets are being applied, and compensate for them immediately. A similar compensation is applied to render_saved_view. Closes: https://github.com/swaywm/sway/issues/6223 (cherry picked from commit 4e6f51525308a8883bf998a360a192edc0822cdd)
-rw-r--r--sway/desktop/render.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/sway/desktop/render.c b/sway/desktop/render.c
index 608f3ee9..58e263e2 100644
--- a/sway/desktop/render.c
+++ b/sway/desktop/render.c
@@ -32,7 +32,7 @@
32struct render_data { 32struct render_data {
33 pixman_region32_t *damage; 33 pixman_region32_t *damage;
34 float alpha; 34 float alpha;
35 struct sway_container *container; 35 struct wlr_box *clip_box;
36}; 36};
37 37
38/** 38/**
@@ -160,10 +160,10 @@ static void render_surface_iterator(struct sway_output *output, struct sway_view
160 wlr_output->transform_matrix); 160 wlr_output->transform_matrix);
161 161
162 struct wlr_box dst_box = *_box; 162 struct wlr_box dst_box = *_box;
163 struct sway_container *container = data->container; 163 struct wlr_box *clip_box = data->clip_box;
164 if (container != NULL) { 164 if (clip_box != NULL) {
165 dst_box.width = fmin(dst_box.width, container->current.content_width); 165 dst_box.width = fmin(dst_box.width, clip_box->width);
166 dst_box.height = fmin(dst_box.height, container->current.content_height); 166 dst_box.height = fmin(dst_box.height, clip_box->height);
167 } 167 }
168 scale_box(&dst_box, wlr_output->scale); 168 scale_box(&dst_box, wlr_output->scale);
169 169
@@ -265,8 +265,13 @@ static void render_view_toplevels(struct sway_view *view,
265 .damage = damage, 265 .damage = damage,
266 .alpha = alpha, 266 .alpha = alpha,
267 }; 267 };
268 struct wlr_box clip_box;
268 if (!container_is_current_floating(view->container)) { 269 if (!container_is_current_floating(view->container)) {
269 data.container = view->container; 270 // As we pass the geometry offsets to the surface iterator, we will
271 // need to account for the offsets in the clip dimensions.
272 clip_box.width = view->container->current.content_width + view->geometry.x;
273 clip_box.height = view->container->current.content_height + view->geometry.y;
274 data.clip_box = &clip_box;
270 } 275 }
271 // Render all toplevels without descending into popups 276 // Render all toplevels without descending into popups
272 double ox = view->container->surface_x - 277 double ox = view->container->surface_x -
@@ -332,10 +337,10 @@ static void render_saved_view(struct sway_view *view,
332 if (!floating) { 337 if (!floating) {
333 dst_box.width = fmin(dst_box.width, 338 dst_box.width = fmin(dst_box.width,
334 view->container->current.content_width - 339 view->container->current.content_width -
335 (saved_buf->x - view->container->current.content_x)); 340 (saved_buf->x - view->container->current.content_x) + view->saved_geometry.x);
336 dst_box.height = fmin(dst_box.height, 341 dst_box.height = fmin(dst_box.height,
337 view->container->current.content_height - 342 view->container->current.content_height -
338 (saved_buf->y - view->container->current.content_y)); 343 (saved_buf->y - view->container->current.content_y) + view->saved_geometry.y);
339 } 344 }
340 scale_box(&dst_box, wlr_output->scale); 345 scale_box(&dst_box, wlr_output->scale);
341 346