summaryrefslogtreecommitdiffstats
path: root/sway/desktop/render.c
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-08-01 16:23:11 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-08-01 16:24:15 +1000
commitd10ccc1eb144e4de2477398f6b11753f6b7df70b (patch)
treea4792f1ca754ed427a5b472d1bcf3e75fcf1f2ef /sway/desktop/render.c
parentMerge pull request #2395 from RedSoxFan/create-mouse-binding-list (diff)
downloadsway-d10ccc1eb144e4de2477398f6b11753f6b7df70b.tar.gz
sway-d10ccc1eb144e4de2477398f6b11753f6b7df70b.tar.zst
sway-d10ccc1eb144e4de2477398f6b11753f6b7df70b.zip
Correctly track saved surfaces during multiple transactions
Fixes #2364. Suppose a view is 600px wide, and we tell it to resize to 601px during a resize operation. We create a transaction, save the 600px buffer and send the configure. This buffer is saved into the associated instruction, and is rendered while we wait for the view to commit a 601px buffer. Before the view commits the 601px buffer, suppose we tell it to resize to 602px. The new transaction will also save the buffer, but it's still the 600px buffer because we haven't received a new one yet. Then suppose the view commits its original 601px buffer. This completes the first transaction, so we apply the 601px width to the container. There's still the second (now only) transaction remaining, so we render the saved buffer from that. But this is still the 600px buffer, and we believe it's 601px. Whoops. The problem here is we can't stack buffers like this. So this commit removes the saved buffer from the instructions, places it in the view instead, and re-saves the latest buffer every time the view completes a transaction and still has further pending transactions. As saved buffers are now specific to views rather than instructions, the functions for saving and removing the saved buffer have been moved to view.c. The calls to save and restore the buffer have been relocated to more appropriate functions too, favouring transaction_commit and transaction_apply rather than transaction_add_container and transaction_destroy.
Diffstat (limited to 'sway/desktop/render.c')
-rw-r--r--sway/desktop/render.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/sway/desktop/render.c b/sway/desktop/render.c
index f25055b8..f0e47c95 100644
--- a/sway/desktop/render.c
+++ b/sway/desktop/render.c
@@ -199,17 +199,14 @@ static void render_saved_view(struct sway_view *view,
199 struct sway_output *output, pixman_region32_t *damage, float alpha) { 199 struct sway_output *output, pixman_region32_t *damage, float alpha) {
200 struct wlr_output *wlr_output = output->wlr_output; 200 struct wlr_output *wlr_output = output->wlr_output;
201 201
202 int width, height; 202 if (!view->saved_buffer || !view->saved_buffer->texture) {
203 struct wlr_texture *texture =
204 transaction_get_saved_texture(view, &width, &height);
205 if (!texture) {
206 return; 203 return;
207 } 204 }
208 struct wlr_box box = { 205 struct wlr_box box = {
209 .x = view->swayc->current.view_x - output->swayc->current.swayc_x, 206 .x = view->swayc->current.view_x - output->swayc->current.swayc_x,
210 .y = view->swayc->current.view_y - output->swayc->current.swayc_y, 207 .y = view->swayc->current.view_y - output->swayc->current.swayc_y,
211 .width = width, 208 .width = view->saved_buffer_width,
212 .height = height, 209 .height = view->saved_buffer_height,
213 }; 210 };
214 211
215 struct wlr_box output_box = { 212 struct wlr_box output_box = {
@@ -229,7 +226,8 @@ static void render_saved_view(struct sway_view *view,
229 wlr_matrix_project_box(matrix, &box, WL_OUTPUT_TRANSFORM_NORMAL, 0, 226 wlr_matrix_project_box(matrix, &box, WL_OUTPUT_TRANSFORM_NORMAL, 0,
230 wlr_output->transform_matrix); 227 wlr_output->transform_matrix);
231 228
232 render_texture(wlr_output, damage, texture, &box, matrix, alpha); 229 render_texture(wlr_output, damage, view->saved_buffer->texture,
230 &box, matrix, alpha);
233} 231}
234 232
235/** 233/**
@@ -238,7 +236,7 @@ static void render_saved_view(struct sway_view *view,
238static void render_view(struct sway_output *output, pixman_region32_t *damage, 236static void render_view(struct sway_output *output, pixman_region32_t *damage,
239 struct sway_container *con, struct border_colors *colors) { 237 struct sway_container *con, struct border_colors *colors) {
240 struct sway_view *view = con->sway_view; 238 struct sway_view *view = con->sway_view;
241 if (view->swayc->instructions->length) { 239 if (view->saved_buffer) {
242 render_saved_view(view, output, damage, view->swayc->alpha); 240 render_saved_view(view, output, damage, view->swayc->alpha);
243 } else { 241 } else {
244 render_view_surfaces(view, output, damage, view->swayc->alpha); 242 render_view_surfaces(view, output, damage, view->swayc->alpha);
@@ -841,7 +839,7 @@ void output_render(struct sway_output *output, struct timespec *when,
841 839
842 // TODO: handle views smaller than the output 840 // TODO: handle views smaller than the output
843 if (fullscreen_con->type == C_VIEW) { 841 if (fullscreen_con->type == C_VIEW) {
844 if (fullscreen_con->instructions->length) { 842 if (fullscreen_con->sway_view->saved_buffer) {
845 render_saved_view(fullscreen_con->sway_view, 843 render_saved_view(fullscreen_con->sway_view,
846 output, damage, 1.0f); 844 output, damage, 1.0f);
847 } else { 845 } else {