aboutsummaryrefslogtreecommitdiffstats
path: root/sway/commands/move.c
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-06-29 19:36:22 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-06-29 19:36:22 +1000
commite8fb6b3325ee545312c092f0b103eea2424fce9f (patch)
tree52870d3f582b281751ca6af93d268d1e9c57f382 /sway/commands/move.c
parentAllow views to skip configures (diff)
downloadsway-e8fb6b3325ee545312c092f0b103eea2424fce9f.tar.gz
sway-e8fb6b3325ee545312c092f0b103eea2424fce9f.tar.zst
sway-e8fb6b3325ee545312c092f0b103eea2424fce9f.zip
Fix crash when moving last child of a container to workspace or output
We were arranging a parent which may have been deleted by the reaper, which meant the `current` children list of the surviving parent had a dangling pointer. Instead, we now reap the workspace.
Diffstat (limited to 'sway/commands/move.c')
-rw-r--r--sway/commands/move.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/sway/commands/move.c b/sway/commands/move.c
index 4ce8d089..4061df3a 100644
--- a/sway/commands/move.c
+++ b/sway/commands/move.c
@@ -90,6 +90,7 @@ static struct cmd_results *cmd_move_container(struct sway_container *current,
90 } 90 }
91 free(ws_name); 91 free(ws_name);
92 struct sway_container *old_parent = current->parent; 92 struct sway_container *old_parent = current->parent;
93 struct sway_container *old_ws = container_parent(current, C_WORKSPACE);
93 struct sway_container *destination = seat_get_focus_inactive( 94 struct sway_container *destination = seat_get_focus_inactive(
94 config->handler_context.seat, ws); 95 config->handler_context.seat, ws);
95 container_move_to(current, destination); 96 container_move_to(current, destination);
@@ -99,8 +100,11 @@ static struct cmd_results *cmd_move_container(struct sway_container *current,
99 container_reap_empty(old_parent); 100 container_reap_empty(old_parent);
100 container_reap_empty(destination->parent); 101 container_reap_empty(destination->parent);
101 102
103 // TODO: Ideally we would arrange the surviving parent after reaping,
104 // but container_reap_empty does not return it, so we arrange the
105 // workspace instead.
102 struct sway_transaction *txn = transaction_create(); 106 struct sway_transaction *txn = transaction_create();
103 arrange_windows(old_parent, txn); 107 arrange_windows(old_ws, txn);
104 arrange_windows(destination->parent, txn); 108 arrange_windows(destination->parent, txn);
105 transaction_commit(txn); 109 transaction_commit(txn);
106 110
@@ -129,13 +133,17 @@ static struct cmd_results *cmd_move_container(struct sway_container *current,
129 focus = destination->children->items[0]; 133 focus = destination->children->items[0];
130 } 134 }
131 struct sway_container *old_parent = current->parent; 135 struct sway_container *old_parent = current->parent;
136 struct sway_container *old_ws = container_parent(current, C_WORKSPACE);
132 container_move_to(current, focus); 137 container_move_to(current, focus);
133 seat_set_focus(config->handler_context.seat, old_parent); 138 seat_set_focus(config->handler_context.seat, old_parent);
134 container_reap_empty(old_parent); 139 container_reap_empty(old_parent);
135 container_reap_empty(focus->parent); 140 container_reap_empty(focus->parent);
136 141
142 // TODO: Ideally we would arrange the surviving parent after reaping,
143 // but container_reap_empty does not return it, so we arrange the
144 // workspace instead.
137 struct sway_transaction *txn = transaction_create(); 145 struct sway_transaction *txn = transaction_create();
138 arrange_windows(old_parent, txn); 146 arrange_windows(old_ws, txn);
139 arrange_windows(focus->parent, txn); 147 arrange_windows(focus->parent, txn);
140 transaction_commit(txn); 148 transaction_commit(txn);
141 149