diff options
author | 2021-02-08 00:51:10 +0100 | |
---|---|---|
committer | 2021-02-09 09:37:10 +0100 | |
commit | cf1e3be22813d343ec177d48a926d7d9104230dd (patch) | |
tree | e2c47101f4db1aa439951dbefa10ea0dcb006881 | |
parent | swaynag: Use position from wl_pointer.enter (diff) | |
download | sway-cf1e3be22813d343ec177d48a926d7d9104230dd.tar.gz sway-cf1e3be22813d343ec177d48a926d7d9104230dd.tar.zst sway-cf1e3be22813d343ec177d48a926d7d9104230dd.zip |
view: Save surface x and y on saved buffers
We need to use surface_x and surface_y when rendering and damaging saved
buffers as these compensate for views that have been centered due to
being smaller than their container.
Add them to the surface positions on the saved buffer so we have the
values from the time the buffer was saved.
-rw-r--r-- | sway/desktop/render.c | 6 | ||||
-rw-r--r-- | sway/desktop/transaction.c | 4 | ||||
-rw-r--r-- | sway/tree/view.c | 4 |
3 files changed, 6 insertions, 8 deletions
diff --git a/sway/desktop/render.c b/sway/desktop/render.c index bd85282c..fee19a33 100644 --- a/sway/desktop/render.c +++ b/sway/desktop/render.c | |||
@@ -289,10 +289,8 @@ static void render_saved_view(struct sway_view *view, | |||
289 | } | 289 | } |
290 | 290 | ||
291 | struct wlr_box box = { | 291 | struct wlr_box box = { |
292 | .x = view->container->surface_x - output->lx - | 292 | .x = saved_buf->x - view->saved_geometry.x - output->lx, |
293 | view->saved_geometry.x + saved_buf->x, | 293 | .y = saved_buf->y - view->saved_geometry.y - output->ly, |
294 | .y = view->container->surface_y - output->ly - | ||
295 | view->saved_geometry.y + saved_buf->y, | ||
296 | .width = saved_buf->width, | 294 | .width = saved_buf->width, |
297 | .height = saved_buf->height, | 295 | .height = saved_buf->height, |
298 | }; | 296 | }; |
diff --git a/sway/desktop/transaction.c b/sway/desktop/transaction.c index eac38991..2d71ad2b 100644 --- a/sway/desktop/transaction.c +++ b/sway/desktop/transaction.c | |||
@@ -214,8 +214,8 @@ static void apply_container_state(struct sway_container *container, | |||
214 | struct sway_saved_buffer *saved_buf; | 214 | struct sway_saved_buffer *saved_buf; |
215 | wl_list_for_each(saved_buf, &view->saved_buffers, link) { | 215 | wl_list_for_each(saved_buf, &view->saved_buffers, link) { |
216 | struct wlr_box box = { | 216 | struct wlr_box box = { |
217 | .x = container->current.content_x - view->saved_geometry.x + saved_buf->x, | 217 | .x = saved_buf->x - view->saved_geometry.x, |
218 | .y = container->current.content_y - view->saved_geometry.y + saved_buf->y, | 218 | .y = saved_buf->y - view->saved_geometry.y, |
219 | .width = saved_buf->width, | 219 | .width = saved_buf->width, |
220 | .height = saved_buf->height, | 220 | .height = saved_buf->height, |
221 | }; | 221 | }; |
diff --git a/sway/tree/view.c b/sway/tree/view.c index c1ce4e6b..3b1e67ea 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c | |||
@@ -1350,8 +1350,8 @@ static void view_save_buffer_iterator(struct wlr_surface *surface, | |||
1350 | saved_buffer->buffer = surface->buffer; | 1350 | saved_buffer->buffer = surface->buffer; |
1351 | saved_buffer->width = surface->current.width; | 1351 | saved_buffer->width = surface->current.width; |
1352 | saved_buffer->height = surface->current.height; | 1352 | saved_buffer->height = surface->current.height; |
1353 | saved_buffer->x = sx; | 1353 | saved_buffer->x = view->container->surface_x + sx; |
1354 | saved_buffer->y = sy; | 1354 | saved_buffer->y = view->container->surface_y + sy; |
1355 | saved_buffer->transform = surface->current.transform; | 1355 | saved_buffer->transform = surface->current.transform; |
1356 | wlr_surface_get_buffer_source_box(surface, &saved_buffer->source_box); | 1356 | wlr_surface_get_buffer_source_box(surface, &saved_buffer->source_box); |
1357 | wl_list_insert(&view->saved_buffers, &saved_buffer->link); | 1357 | wl_list_insert(&view->saved_buffers, &saved_buffer->link); |