aboutsummaryrefslogtreecommitdiffstats
path: root/sway/tree/arrange.c
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-06-23 16:24:11 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-06-23 16:24:11 +1000
commit38398e2d77d57dc06b67ec88a54091c897915602 (patch)
treec80935807865fd96ab7d037070287d4dfaba1863 /sway/tree/arrange.c
parentPreserve buffers during transactions (diff)
downloadsway-38398e2d77d57dc06b67ec88a54091c897915602.tar.gz
sway-38398e2d77d57dc06b67ec88a54091c897915602.tar.zst
sway-38398e2d77d57dc06b67ec88a54091c897915602.zip
Implement atomic layout updates for tree operations
This implements atomic layout updates for when views map, reparent or unmap.
Diffstat (limited to 'sway/tree/arrange.c')
-rw-r--r--sway/tree/arrange.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/sway/tree/arrange.c b/sway/tree/arrange.c
index ac99c5df..cb3f8ba2 100644
--- a/sway/tree/arrange.c
+++ b/sway/tree/arrange.c
@@ -144,6 +144,19 @@ static void apply_tabbed_or_stacked_layout(struct sway_container *parent) {
144 } 144 }
145} 145}
146 146
147/**
148 * If a container has been deleted from the pending tree state, we must add it
149 * to the transaction so it can be freed afterwards. To do this, we iterate the
150 * server's destroying_containers list and add all of them. We may add more than
151 * what we need to, but this is easy and has no negative consequences.
152 */
153static void add_deleted_containers(struct sway_transaction *transaction) {
154 for (int i = 0; i < server.destroying_containers->length; ++i) {
155 struct sway_container *child = server.destroying_containers->items[i];
156 transaction_add_container(transaction, child);
157 }
158}
159
147static void arrange_children_of(struct sway_container *parent, 160static void arrange_children_of(struct sway_container *parent,
148 struct sway_transaction *transaction); 161 struct sway_transaction *transaction);
149 162
@@ -158,6 +171,7 @@ static void arrange_floating(struct sway_container *floating,
158 } 171 }
159 transaction_add_container(transaction, floater); 172 transaction_add_container(transaction, floater);
160 } 173 }
174 transaction_add_container(transaction, floating);
161} 175}
162 176
163static void arrange_children_of(struct sway_container *parent, 177static void arrange_children_of(struct sway_container *parent,
@@ -290,7 +304,16 @@ void arrange_windows(struct sway_container *container,
290 case C_TYPES: 304 case C_TYPES:
291 break; 305 break;
292 } 306 }
293 transaction_add_damage(transaction, container_get_box(container)); 307 // Add damage for whatever container arrange_windows() was called with,
308 // unless it was called with the special floating container, in which case
309 // we'll damage the entire output.
310 if (container->type == C_CONTAINER && container->layout == L_FLOATING) {
311 struct sway_container *output = container_parent(container, C_OUTPUT);
312 transaction_add_damage(transaction, container_get_box(output));
313 } else {
314 transaction_add_damage(transaction, container_get_box(container));
315 }
316 add_deleted_containers(transaction);
294} 317}
295 318
296void arrange_and_commit(struct sway_container *container) { 319void arrange_and_commit(struct sway_container *container) {