aboutsummaryrefslogtreecommitdiffstats
path: root/sway/tree/container.c
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-07-14 23:14:55 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-07-14 23:14:55 +1000
commit2032f85d94f2f222282b242116b3e827dd458f6c (patch)
treed6ad82f79521cdd948985be22630b803af58afea /sway/tree/container.c
parentMerge pull request #2244 from RyanDwyer/floating-resize (diff)
downloadsway-2032f85d94f2f222282b242116b3e827dd458f6c.tar.gz
sway-2032f85d94f2f222282b242116b3e827dd458f6c.tar.zst
sway-2032f85d94f2f222282b242116b3e827dd458f6c.zip
Simplify transactions by utilising a dirty flag on containers
This PR changes the way we handle transactions to a more simple method. The new method is to mark containers as dirty from low level code (eg. arranging, or container_destroy, and eventually seat_set_focus), then call transaction_commit_dirty which picks up those containers and runs them through a transaction. The old methods of using transactions (arrange_and_commit, or creating one manually) are now no longer possible. The highest-level code (execute_command and view implementation handlers) will call transaction_commit_dirty, so most other code just needs to set containers as dirty. This is done by arranging, but can also be done by calling container_set_dirty.
Diffstat (limited to 'sway/tree/container.c')
-rw-r--r--sway/tree/container.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c
index 58852717..35f67cce 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -159,14 +159,6 @@ void container_free(struct sway_container *cont) {
159 wlr_texture_destroy(cont->title_focused_inactive); 159 wlr_texture_destroy(cont->title_focused_inactive);
160 wlr_texture_destroy(cont->title_unfocused); 160 wlr_texture_destroy(cont->title_unfocused);
161 wlr_texture_destroy(cont->title_urgent); 161 wlr_texture_destroy(cont->title_urgent);
162
163 for (int i = 0; i < server.destroying_containers->length; ++i) {
164 if (server.destroying_containers->items[i] == cont) {
165 list_del(server.destroying_containers, i);
166 break;
167 }
168 }
169
170 list_free(cont->instructions); 162 list_free(cont->instructions);
171 list_free(cont->children); 163 list_free(cont->children);
172 list_free(cont->current.children); 164 list_free(cont->current.children);
@@ -325,7 +317,7 @@ static struct sway_container *container_destroy_noreaping(
325 } 317 }
326 318
327 con->destroying = true; 319 con->destroying = true;
328 list_add(server.destroying_containers, con); 320 container_set_dirty(con);
329 321
330 if (!con->parent) { 322 if (!con->parent) {
331 return NULL; 323 return NULL;
@@ -1069,9 +1061,15 @@ void container_floating_move_to(struct sway_container *con,
1069 if (old_workspace != new_workspace) { 1061 if (old_workspace != new_workspace) {
1070 container_remove_child(con); 1062 container_remove_child(con);
1071 container_add_child(new_workspace->sway_workspace->floating, con); 1063 container_add_child(new_workspace->sway_workspace->floating, con);
1072 struct sway_transaction *transaction = transaction_create(); 1064 arrange_windows(old_workspace);
1073 arrange_windows(old_workspace, transaction); 1065 arrange_windows(new_workspace);
1074 arrange_windows(new_workspace, transaction); 1066 }
1075 transaction_commit(transaction); 1067}
1068
1069void container_set_dirty(struct sway_container *container) {
1070 if (container->dirty) {
1071 return;
1076 } 1072 }
1073 container->dirty = true;
1074 list_add(server.dirty_containers, container);
1077} 1075}