Remove transaction_add_damage

Instead, damage each container when applying the transaction.
master
Ryan Dwyer 7 years ago
parent 61c1187685
commit be86d3aba6

@ -30,13 +30,6 @@ struct sway_transaction *transaction_create(void);
void transaction_add_container(struct sway_transaction *transaction,
struct sway_container *container);
/**
* Add a box to be damaged when the transaction is applied.
* The box should be in layout coordinates.
*/
void transaction_add_damage(struct sway_transaction *transaction,
struct wlr_box *box);
/**
* Submit a transaction to the client views for configuration.
*/

@ -30,7 +30,6 @@
struct sway_transaction {
struct wl_event_source *timer;
list_t *instructions; // struct sway_transaction_instruction *
list_t *damage; // struct wlr_box *
size_t num_waiting;
size_t num_configures;
struct sway_transaction *next;
@ -51,7 +50,6 @@ struct sway_transaction *transaction_create() {
struct sway_transaction *transaction =
calloc(1, sizeof(struct sway_transaction));
transaction->instructions = create_list();
transaction->damage = create_list();
if (server.debug_txn_timings) {
clock_gettime(CLOCK_MONOTONIC, &transaction->create_time);
}
@ -97,10 +95,6 @@ static void transaction_destroy(struct sway_transaction *transaction) {
}
list_free(transaction->instructions);
// Free damage
list_foreach(transaction->damage, free);
list_free(transaction->damage);
if (transaction->timer) {
wl_event_source_remove(transaction->timer);
}
@ -174,13 +168,6 @@ void transaction_add_container(struct sway_transaction *transaction,
list_add(transaction->instructions, instruction);
}
void transaction_add_damage(struct sway_transaction *transaction,
struct wlr_box *_box) {
struct wlr_box *box = calloc(1, sizeof(struct wlr_box));
memcpy(box, _box, sizeof(struct wlr_box));
list_add(transaction->damage, box);
}
/**
* Apply a transaction to the "current" state of the tree.
*/
@ -200,12 +187,32 @@ static void transaction_apply(struct sway_transaction *transaction) {
"%.1fms total (%.1f frames if 60Hz)", transaction,
ms_arranging, ms_waiting, ms_total, ms_total / (1000 / 60));
}
// Apply the instruction state to the container's current state
for (int i = 0; i < transaction->instructions->length; ++i) {
struct sway_transaction_instruction *instruction =
transaction->instructions->items[i];
struct sway_container *container = instruction->container;
// Damage the old and new locations
struct wlr_box old_box = {
.x = container->current.swayc_x,
.y = container->current.swayc_y,
.width = container->current.swayc_width,
.height = container->current.swayc_height,
};
struct wlr_box new_box = {
.x = instruction->state.swayc_x,
.y = instruction->state.swayc_y,
.width = instruction->state.swayc_width,
.height = instruction->state.swayc_height,
};
for (int j = 0; j < root_container.children->length; ++j) {
struct sway_container *output = root_container.children->items[j];
output_damage_box(output->sway_output, &old_box);
output_damage_box(output->sway_output, &new_box);
}
// There are separate children lists for each instruction state, the
// container's current state and the container's pending state
// (ie. con->children). The list itself needs to be freed here.
@ -216,15 +223,6 @@ static void transaction_apply(struct sway_transaction *transaction) {
memcpy(&container->current, &instruction->state,
sizeof(struct sway_container_state));
}
// Apply damage
for (int i = 0; i < transaction->damage->length; ++i) {
struct wlr_box *box = transaction->damage->items[i];
for (int j = 0; j < root_container.children->length; ++j) {
struct sway_container *output = root_container.children->items[j];
output_damage_box(output->sway_output, box);
}
}
}
static void transaction_progress_queue() {

@ -272,10 +272,7 @@ static void handle_request_fullscreen(struct wl_listener *listener, void *data)
view_set_fullscreen(view, e->fullscreen);
struct sway_container *ws = container_parent(view->swayc, C_WORKSPACE);
struct sway_transaction *transaction = transaction_create();
arrange_windows(ws, transaction);
transaction_add_damage(transaction, container_get_box(ws->parent));
transaction_commit(transaction);
arrange_and_commit(ws);
}
void handle_xdg_shell_surface(struct wl_listener *listener, void *data) {

@ -267,10 +267,7 @@ static void handle_request_fullscreen(struct wl_listener *listener, void *data)
view_set_fullscreen(view, e->fullscreen);
struct sway_container *ws = container_parent(view->swayc, C_WORKSPACE);
struct sway_transaction *transaction = transaction_create();
arrange_windows(ws, transaction);
transaction_add_damage(transaction, container_get_box(ws->parent));
transaction_commit(transaction);
arrange_and_commit(ws);
}
void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {

@ -342,10 +342,7 @@ static void handle_request_fullscreen(struct wl_listener *listener, void *data)
view_set_fullscreen(view, xsurface->fullscreen);
struct sway_container *ws = container_parent(view->swayc, C_WORKSPACE);
struct sway_transaction *transaction = transaction_create();
arrange_windows(ws, transaction);
transaction_add_damage(transaction, container_get_box(ws->parent));
transaction_commit(transaction);
arrange_and_commit(ws);
}
static void handle_set_title(struct wl_listener *listener, void *data) {

@ -304,15 +304,6 @@ void arrange_windows(struct sway_container *container,
case C_TYPES:
break;
}
// Add damage for whatever container arrange_windows() was called with,
// unless it was called with the special floating container, in which case
// we'll damage the entire output.
if (container->type == C_CONTAINER && container->layout == L_FLOATING) {
struct sway_container *output = container_parent(container, C_OUTPUT);
transaction_add_damage(transaction, container_get_box(output));
} else {
transaction_add_damage(transaction, container_get_box(container));
}
add_deleted_containers(transaction);
}

@ -550,11 +550,7 @@ void view_unmap(struct sway_view *view) {
ws->sway_workspace->fullscreen = NULL;
container_destroy(view->swayc);
struct sway_container *output = ws->parent;
struct sway_transaction *transaction = transaction_create();
arrange_windows(output, transaction);
transaction_add_damage(transaction, container_get_box(output));
transaction_commit(transaction);
arrange_and_commit(ws->parent);
} else {
struct sway_container *parent = container_destroy(view->swayc);
arrange_and_commit(parent);

Loading…
Cancel
Save