aboutsummaryrefslogtreecommitdiffstats
path: root/sway/desktop/transaction.c
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-06-27 17:46:03 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-06-27 17:46:03 +1000
commitbe86d3aba602fef7b51fafa8a6e7a39d1e49817f (patch)
treeba4e3debd236eb39337cd4f59772b2eaf260195f /sway/desktop/transaction.c
parentFix nitpicks (diff)
downloadsway-be86d3aba602fef7b51fafa8a6e7a39d1e49817f.tar.gz
sway-be86d3aba602fef7b51fafa8a6e7a39d1e49817f.tar.zst
sway-be86d3aba602fef7b51fafa8a6e7a39d1e49817f.zip
Remove transaction_add_damage
Instead, damage each container when applying the transaction.
Diffstat (limited to 'sway/desktop/transaction.c')
-rw-r--r--sway/desktop/transaction.c42
1 files changed, 20 insertions, 22 deletions
diff --git a/sway/desktop/transaction.c b/sway/desktop/transaction.c
index 98cde889..c29b6661 100644
--- a/sway/desktop/transaction.c
+++ b/sway/desktop/transaction.c
@@ -30,7 +30,6 @@
30struct sway_transaction { 30struct sway_transaction {
31 struct wl_event_source *timer; 31 struct wl_event_source *timer;
32 list_t *instructions; // struct sway_transaction_instruction * 32 list_t *instructions; // struct sway_transaction_instruction *
33 list_t *damage; // struct wlr_box *
34 size_t num_waiting; 33 size_t num_waiting;
35 size_t num_configures; 34 size_t num_configures;
36 struct sway_transaction *next; 35 struct sway_transaction *next;
@@ -51,7 +50,6 @@ struct sway_transaction *transaction_create() {
51 struct sway_transaction *transaction = 50 struct sway_transaction *transaction =
52 calloc(1, sizeof(struct sway_transaction)); 51 calloc(1, sizeof(struct sway_transaction));
53 transaction->instructions = create_list(); 52 transaction->instructions = create_list();
54 transaction->damage = create_list();
55 if (server.debug_txn_timings) { 53 if (server.debug_txn_timings) {
56 clock_gettime(CLOCK_MONOTONIC, &transaction->create_time); 54 clock_gettime(CLOCK_MONOTONIC, &transaction->create_time);
57 } 55 }
@@ -97,10 +95,6 @@ static void transaction_destroy(struct sway_transaction *transaction) {
97 } 95 }
98 list_free(transaction->instructions); 96 list_free(transaction->instructions);
99 97
100 // Free damage
101 list_foreach(transaction->damage, free);
102 list_free(transaction->damage);
103
104 if (transaction->timer) { 98 if (transaction->timer) {
105 wl_event_source_remove(transaction->timer); 99 wl_event_source_remove(transaction->timer);
106 } 100 }
@@ -174,13 +168,6 @@ void transaction_add_container(struct sway_transaction *transaction,
174 list_add(transaction->instructions, instruction); 168 list_add(transaction->instructions, instruction);
175} 169}
176 170
177void transaction_add_damage(struct sway_transaction *transaction,
178 struct wlr_box *_box) {
179 struct wlr_box *box = calloc(1, sizeof(struct wlr_box));
180 memcpy(box, _box, sizeof(struct wlr_box));
181 list_add(transaction->damage, box);
182}
183
184/** 171/**
185 * Apply a transaction to the "current" state of the tree. 172 * Apply a transaction to the "current" state of the tree.
186 */ 173 */
@@ -200,12 +187,32 @@ static void transaction_apply(struct sway_transaction *transaction) {
200 "%.1fms total (%.1f frames if 60Hz)", transaction, 187 "%.1fms total (%.1f frames if 60Hz)", transaction,
201 ms_arranging, ms_waiting, ms_total, ms_total / (1000 / 60)); 188 ms_arranging, ms_waiting, ms_total, ms_total / (1000 / 60));
202 } 189 }
190
203 // Apply the instruction state to the container's current state 191 // Apply the instruction state to the container's current state
204 for (int i = 0; i < transaction->instructions->length; ++i) { 192 for (int i = 0; i < transaction->instructions->length; ++i) {
205 struct sway_transaction_instruction *instruction = 193 struct sway_transaction_instruction *instruction =
206 transaction->instructions->items[i]; 194 transaction->instructions->items[i];
207 struct sway_container *container = instruction->container; 195 struct sway_container *container = instruction->container;
208 196
197 // Damage the old and new locations
198 struct wlr_box old_box = {
199 .x = container->current.swayc_x,
200 .y = container->current.swayc_y,
201 .width = container->current.swayc_width,
202 .height = container->current.swayc_height,
203 };
204 struct wlr_box new_box = {
205 .x = instruction->state.swayc_x,
206 .y = instruction->state.swayc_y,
207 .width = instruction->state.swayc_width,
208 .height = instruction->state.swayc_height,
209 };
210 for (int j = 0; j < root_container.children->length; ++j) {
211 struct sway_container *output = root_container.children->items[j];
212 output_damage_box(output->sway_output, &old_box);
213 output_damage_box(output->sway_output, &new_box);
214 }
215
209 // There are separate children lists for each instruction state, the 216 // There are separate children lists for each instruction state, the
210 // container's current state and the container's pending state 217 // container's current state and the container's pending state
211 // (ie. con->children). The list itself needs to be freed here. 218 // (ie. con->children). The list itself needs to be freed here.
@@ -216,15 +223,6 @@ static void transaction_apply(struct sway_transaction *transaction) {
216 memcpy(&container->current, &instruction->state, 223 memcpy(&container->current, &instruction->state,
217 sizeof(struct sway_container_state)); 224 sizeof(struct sway_container_state));
218 } 225 }
219
220 // Apply damage
221 for (int i = 0; i < transaction->damage->length; ++i) {
222 struct wlr_box *box = transaction->damage->items[i];
223 for (int j = 0; j < root_container.children->length; ++j) {
224 struct sway_container *output = root_container.children->items[j];
225 output_damage_box(output->sway_output, box);
226 }
227 }
228} 226}
229 227
230static void transaction_progress_queue() { 228static void transaction_progress_queue() {