summaryrefslogtreecommitdiff
path: root/sway/desktop/transaction.c
diff options
context:
space:
mode:
authorRyan Dwyer <[email protected]>2018-06-18 20:42:12 +1000
committerRyan Dwyer <[email protected]>2018-06-18 20:42:12 +1000
commit1c89f32533534f6e78c81c95578f40df45bb9016 (patch)
tree98ba154e1cbd5148e9b7178037c26a3dadcec839 /sway/desktop/transaction.c
parent645bf446fab8db581b04babb1a34aa3c40428058 (diff)
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.c28
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 @@
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
+#include <wlr/types/wlr_buffer.h>
#include <wlr/types/wlr_linux_dmabuf.h>
#include "sway/debug.h"
#include "sway/desktop/transaction.h"
@@ -112,16 +113,23 @@ void transaction_add_damage(struct sway_transaction *transaction,
list_add(transaction->damage, box);
}
-static void save_view_texture(struct sway_view *view) {
- wlr_texture_destroy(view->saved_texture);
- view->saved_texture = NULL;
-
- // TODO: Copy the texture and store it in view->saved_texture.
+static void save_view_buffer(struct sway_view *view) {
+ if (view->saved_buffer) {
+ wlr_buffer_unref(view->saved_buffer);
+ }
+ wlr_buffer_ref(view->surface->buffer);
+ view->saved_buffer = view->surface->buffer;
+ view->saved_surface_width = view->surface->current->width;
+ view->saved_surface_height = view->surface->current->height;
}
-static void remove_saved_view_texture(struct sway_view *view) {
- wlr_texture_destroy(view->saved_texture);
- view->saved_texture = NULL;
+static void remove_saved_view_buffer(struct sway_view *view) {
+ if (view->saved_buffer) {
+ wlr_buffer_unref(view->saved_buffer);
+ view->saved_buffer = NULL;
+ view->saved_surface_width = 0;
+ view->saved_surface_height = 0;
+ }
}
/**
@@ -141,7 +149,7 @@ static void transaction_apply(struct sway_transaction *transaction) {
sizeof(struct sway_container_state));
if (container->type == C_VIEW) {
- remove_saved_view_texture(container->sway_view);
+ remove_saved_view_buffer(container->sway_view);
}
}
@@ -183,7 +191,7 @@ void transaction_commit(struct sway_transaction *transaction) {
instruction->state.view_width,
instruction->state.view_height);
if (instruction->serial) {
- save_view_texture(con->sway_view);
+ save_view_buffer(con->sway_view);
list_add(con->sway_view->instructions, instruction);
++transaction->num_waiting;
}