|
|
@ -41,8 +41,6 @@ struct sway_transaction_instruction {
|
|
|
|
struct sway_transaction *transaction;
|
|
|
|
struct sway_transaction *transaction;
|
|
|
|
struct sway_container *container;
|
|
|
|
struct sway_container *container;
|
|
|
|
struct sway_container_state state;
|
|
|
|
struct sway_container_state state;
|
|
|
|
struct wlr_buffer *saved_buffer;
|
|
|
|
|
|
|
|
int saved_buffer_width, saved_buffer_height;
|
|
|
|
|
|
|
|
uint32_t serial;
|
|
|
|
uint32_t serial;
|
|
|
|
bool ready;
|
|
|
|
bool ready;
|
|
|
|
};
|
|
|
|
};
|
|
|
@ -57,27 +55,6 @@ static struct sway_transaction *transaction_create() {
|
|
|
|
return transaction;
|
|
|
|
return transaction;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void remove_saved_view_buffer(
|
|
|
|
|
|
|
|
struct sway_transaction_instruction *instruction) {
|
|
|
|
|
|
|
|
if (instruction->saved_buffer) {
|
|
|
|
|
|
|
|
wlr_buffer_unref(instruction->saved_buffer);
|
|
|
|
|
|
|
|
instruction->saved_buffer = NULL;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void save_view_buffer(struct sway_view *view,
|
|
|
|
|
|
|
|
struct sway_transaction_instruction *instruction) {
|
|
|
|
|
|
|
|
if (!sway_assert(instruction->saved_buffer == NULL,
|
|
|
|
|
|
|
|
"Didn't expect instruction to have a saved buffer already")) {
|
|
|
|
|
|
|
|
remove_saved_view_buffer(instruction);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (view->surface && wlr_surface_has_buffer(view->surface)) {
|
|
|
|
|
|
|
|
instruction->saved_buffer = wlr_buffer_ref(view->surface->buffer);
|
|
|
|
|
|
|
|
instruction->saved_buffer_width = view->surface->current.width;
|
|
|
|
|
|
|
|
instruction->saved_buffer_height = view->surface->current.height;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void transaction_destroy(struct sway_transaction *transaction) {
|
|
|
|
static void transaction_destroy(struct sway_transaction *transaction) {
|
|
|
|
// Free instructions
|
|
|
|
// Free instructions
|
|
|
|
for (int i = 0; i < transaction->instructions->length; ++i) {
|
|
|
|
for (int i = 0; i < transaction->instructions->length; ++i) {
|
|
|
@ -93,7 +70,6 @@ static void transaction_destroy(struct sway_transaction *transaction) {
|
|
|
|
if (con->destroying && !con->instructions->length) {
|
|
|
|
if (con->destroying && !con->instructions->length) {
|
|
|
|
container_free(con);
|
|
|
|
container_free(con);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
remove_saved_view_buffer(instruction);
|
|
|
|
|
|
|
|
free(instruction);
|
|
|
|
free(instruction);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
list_free(transaction->instructions);
|
|
|
|
list_free(transaction->instructions);
|
|
|
@ -158,9 +134,6 @@ static void transaction_add_container(struct sway_transaction *transaction,
|
|
|
|
|
|
|
|
|
|
|
|
copy_pending_state(container, &instruction->state);
|
|
|
|
copy_pending_state(container, &instruction->state);
|
|
|
|
|
|
|
|
|
|
|
|
if (container->type == C_VIEW) {
|
|
|
|
|
|
|
|
save_view_buffer(container->sway_view, instruction);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
list_add(transaction->instructions, instruction);
|
|
|
|
list_add(transaction->instructions, instruction);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -220,6 +193,22 @@ static void transaction_apply(struct sway_transaction *transaction) {
|
|
|
|
|
|
|
|
|
|
|
|
memcpy(&container->current, &instruction->state,
|
|
|
|
memcpy(&container->current, &instruction->state,
|
|
|
|
sizeof(struct sway_container_state));
|
|
|
|
sizeof(struct sway_container_state));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (container->type == C_VIEW) {
|
|
|
|
|
|
|
|
if (container->destroying) {
|
|
|
|
|
|
|
|
if (container->instructions->length == 1 &&
|
|
|
|
|
|
|
|
container->sway_view->saved_buffer) {
|
|
|
|
|
|
|
|
view_remove_saved_buffer(container->sway_view);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if (container->sway_view->saved_buffer) {
|
|
|
|
|
|
|
|
view_remove_saved_buffer(container->sway_view);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (container->instructions->length > 1) {
|
|
|
|
|
|
|
|
view_save_buffer(container->sway_view);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -295,6 +284,9 @@ static void transaction_commit(struct sway_transaction *transaction) {
|
|
|
|
struct timespec when;
|
|
|
|
struct timespec when;
|
|
|
|
wlr_surface_send_frame_done(con->sway_view->surface, &when);
|
|
|
|
wlr_surface_send_frame_done(con->sway_view->surface, &when);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (con->type == C_VIEW && !con->sway_view->saved_buffer) {
|
|
|
|
|
|
|
|
view_save_buffer(con->sway_view);
|
|
|
|
|
|
|
|
}
|
|
|
|
list_add(con->instructions, instruction);
|
|
|
|
list_add(con->instructions, instruction);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
transaction->num_configures = transaction->num_waiting;
|
|
|
|
transaction->num_configures = transaction->num_waiting;
|
|
|
@ -400,18 +392,6 @@ void transaction_notify_view_ready_by_size(struct sway_view *view,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct wlr_texture *transaction_get_saved_texture(struct sway_view *view,
|
|
|
|
|
|
|
|
int *width, int *height) {
|
|
|
|
|
|
|
|
struct sway_transaction_instruction *instruction =
|
|
|
|
|
|
|
|
view->swayc->instructions->items[0];
|
|
|
|
|
|
|
|
if (!instruction->saved_buffer) {
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
*width = instruction->saved_buffer_width;
|
|
|
|
|
|
|
|
*height = instruction->saved_buffer_height;
|
|
|
|
|
|
|
|
return instruction->saved_buffer->texture;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void transaction_commit_dirty(void) {
|
|
|
|
void transaction_commit_dirty(void) {
|
|
|
|
if (!server.dirty_containers->length) {
|
|
|
|
if (!server.dirty_containers->length) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|