diff options
author | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-06-18 20:42:12 +1000 |
---|---|---|
committer | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-06-18 20:42:12 +1000 |
commit | 1c89f32533534f6e78c81c95578f40df45bb9016 (patch) | |
tree | 98ba154e1cbd5148e9b7178037c26a3dadcec839 /sway/desktop/transaction.c | |
parent | Merge remote-tracking branch 'upstream/master' into atomic (diff) | |
download | sway-1c89f32533534f6e78c81c95578f40df45bb9016.tar.gz sway-1c89f32533534f6e78c81c95578f40df45bb9016.tar.zst sway-1c89f32533534f6e78c81c95578f40df45bb9016.zip |
Preserve buffers during transactions
* Also fix parts of the rendering where it was rendering the pending
state instead of current.
Diffstat (limited to 'sway/desktop/transaction.c')
-rw-r--r-- | sway/desktop/transaction.c | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/sway/desktop/transaction.c b/sway/desktop/transaction.c index 07bfbf7a..77377a18 100644 --- a/sway/desktop/transaction.c +++ b/sway/desktop/transaction.c | |||
@@ -2,6 +2,7 @@ | |||
2 | #include <stdbool.h> | 2 | #include <stdbool.h> |
3 | #include <stdlib.h> | 3 | #include <stdlib.h> |
4 | #include <string.h> | 4 | #include <string.h> |
5 | #include <wlr/types/wlr_buffer.h> | ||
5 | #include <wlr/types/wlr_linux_dmabuf.h> | 6 | #include <wlr/types/wlr_linux_dmabuf.h> |
6 | #include "sway/debug.h" | 7 | #include "sway/debug.h" |
7 | #include "sway/desktop/transaction.h" | 8 | #include "sway/desktop/transaction.h" |
@@ -112,16 +113,23 @@ void transaction_add_damage(struct sway_transaction *transaction, | |||
112 | list_add(transaction->damage, box); | 113 | list_add(transaction->damage, box); |
113 | } | 114 | } |
114 | 115 | ||
115 | static void save_view_texture(struct sway_view *view) { | 116 | static void save_view_buffer(struct sway_view *view) { |
116 | wlr_texture_destroy(view->saved_texture); | 117 | if (view->saved_buffer) { |
117 | view->saved_texture = NULL; | 118 | wlr_buffer_unref(view->saved_buffer); |
118 | 119 | } | |
119 | // TODO: Copy the texture and store it in view->saved_texture. | 120 | wlr_buffer_ref(view->surface->buffer); |
121 | view->saved_buffer = view->surface->buffer; | ||
122 | view->saved_surface_width = view->surface->current->width; | ||
123 | view->saved_surface_height = view->surface->current->height; | ||
120 | } | 124 | } |
121 | 125 | ||
122 | static void remove_saved_view_texture(struct sway_view *view) { | 126 | static void remove_saved_view_buffer(struct sway_view *view) { |
123 | wlr_texture_destroy(view->saved_texture); | 127 | if (view->saved_buffer) { |
124 | view->saved_texture = NULL; | 128 | wlr_buffer_unref(view->saved_buffer); |
129 | view->saved_buffer = NULL; | ||
130 | view->saved_surface_width = 0; | ||
131 | view->saved_surface_height = 0; | ||
132 | } | ||
125 | } | 133 | } |
126 | 134 | ||
127 | /** | 135 | /** |
@@ -141,7 +149,7 @@ static void transaction_apply(struct sway_transaction *transaction) { | |||
141 | sizeof(struct sway_container_state)); | 149 | sizeof(struct sway_container_state)); |
142 | 150 | ||
143 | if (container->type == C_VIEW) { | 151 | if (container->type == C_VIEW) { |
144 | remove_saved_view_texture(container->sway_view); | 152 | remove_saved_view_buffer(container->sway_view); |
145 | } | 153 | } |
146 | } | 154 | } |
147 | 155 | ||
@@ -183,7 +191,7 @@ void transaction_commit(struct sway_transaction *transaction) { | |||
183 | instruction->state.view_width, | 191 | instruction->state.view_width, |
184 | instruction->state.view_height); | 192 | instruction->state.view_height); |
185 | if (instruction->serial) { | 193 | if (instruction->serial) { |
186 | save_view_texture(con->sway_view); | 194 | save_view_buffer(con->sway_view); |
187 | list_add(con->sway_view->instructions, instruction); | 195 | list_add(con->sway_view->instructions, instruction); |
188 | ++transaction->num_waiting; | 196 | ++transaction->num_waiting; |
189 | } | 197 | } |