aboutsummaryrefslogtreecommitdiffstats
path: root/sway/desktop/render.c
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-04-26 09:24:12 +0200
commit4e6f51525308a8883bf998a360a192edc0822cdd (patch)
tree7b9f8eb230e971c5588f8a9d8de2a0ff5c6eecab /sway/desktop/render.c
parentRemove usage of surface->sx|sy (diff)
downloadsway-4e6f51525308a8883bf998a360a192edc0822cdd.tar.gz
sway-4e6f51525308a8883bf998a360a192edc0822cdd.tar.zst
sway-4e6f51525308a8883bf998a360a192edc0822cdd.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
Diffstat (limited to 'sway/desktop/render.c')
-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 42d62b90..8f1e9c52 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/**
@@ -157,10 +157,10 @@ static void render_surface_iterator(struct sway_output *output, struct sway_view
157 wlr_output->transform_matrix); 157 wlr_output->transform_matrix);
158 158
159 struct wlr_box dst_box = *_box; 159 struct wlr_box dst_box = *_box;
160 struct sway_container *container = data->container; 160 struct wlr_box *clip_box = data->clip_box;
161 if (container != NULL) { 161 if (clip_box != NULL) {
162 dst_box.width = fmin(dst_box.width, container->current.content_width); 162 dst_box.width = fmin(dst_box.width, clip_box->width);
163 dst_box.height = fmin(dst_box.height, container->current.content_height); 163 dst_box.height = fmin(dst_box.height, clip_box->height);
164 } 164 }
165 scale_box(&dst_box, wlr_output->scale); 165 scale_box(&dst_box, wlr_output->scale);
166 166
@@ -262,8 +262,13 @@ static void render_view_toplevels(struct sway_view *view,
262 .damage = damage, 262 .damage = damage,
263 .alpha = alpha, 263 .alpha = alpha,
264 }; 264 };
265 struct wlr_box clip_box;
265 if (!container_is_current_floating(view->container)) { 266 if (!container_is_current_floating(view->container)) {
266 data.container = view->container; 267 // As we pass the geometry offsets to the surface iterator, we will
268 // need to account for the offsets in the clip dimensions.
269 clip_box.width = view->container->current.content_width + view->geometry.x;
270 clip_box.height = view->container->current.content_height + view->geometry.y;
271 data.clip_box = &clip_box;
267 } 272 }
268 // Render all toplevels without descending into popups 273 // Render all toplevels without descending into popups
269 double ox = view->container->surface_x - 274 double ox = view->container->surface_x -
@@ -329,10 +334,10 @@ static void render_saved_view(struct sway_view *view,
329 if (!floating) { 334 if (!floating) {
330 dst_box.width = fmin(dst_box.width, 335 dst_box.width = fmin(dst_box.width,
331 view->container->current.content_width - 336 view->container->current.content_width -
332 (saved_buf->x - view->container->current.content_x)); 337 (saved_buf->x - view->container->current.content_x) + view->saved_geometry.x);
333 dst_box.height = fmin(dst_box.height, 338 dst_box.height = fmin(dst_box.height,
334 view->container->current.content_height - 339 view->container->current.content_height -
335 (saved_buf->y - view->container->current.content_y)); 340 (saved_buf->y - view->container->current.content_y) + view->saved_geometry.y);
336 } 341 }
337 scale_box(&dst_box, wlr_output->scale); 342 scale_box(&dst_box, wlr_output->scale);
338 343