aboutsummaryrefslogtreecommitdiff
path: root/sway/commands
diff options
context:
space:
mode:
authorRyan Dwyer <ryandwyer1@gmail.com>2018-06-24 15:50:53 +1000
committerRyan Dwyer <ryandwyer1@gmail.com>2018-06-24 15:50:53 +1000
commitb864ac0149212adf753824366e20badfa971b29f (patch)
tree87f9a4117a84d3552c25a2434094d221c7d6bad0 /sway/commands
parent33e03cb27795b267bcd3c7508363ec8f95127e95 (diff)
downloadsway-b864ac0149212adf753824366e20badfa971b29f.tar.xz
Fix crash when unmapping a view with reapable parents
container_destroy was calling container_reap_empty, which calls container_destroy and so on. Eventually the original container_destroy would return a NULL pointer to the caller which caused a crash. This also fixes an arrange on the wrong container when moving views in and out of stacks.
Diffstat (limited to 'sway/commands')
-rw-r--r--sway/commands/move.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/sway/commands/move.c b/sway/commands/move.c
index 2c9fb77a..da0f89e9 100644
--- a/sway/commands/move.c
+++ b/sway/commands/move.c
@@ -177,13 +177,19 @@ static struct cmd_results *cmd_move_workspace(struct sway_container *current,
static void move_in_direction(struct sway_container *container,
enum wlr_direction direction, int move_amt) {
- struct sway_container *old_parent = container->parent;
+ // For simplicity, we'll arrange the entire workspace. The reason for this
+ // is moving the container might reap the old parent, and container_move
+ // does not return a surviving parent.
+ // TODO: Make container_move return the surviving parent so we can arrange
+ // just that.
+ struct sway_container *old_ws = container_parent(container, C_WORKSPACE);
container_move(container, direction, move_amt);
+ struct sway_container *new_ws = container_parent(container, C_WORKSPACE);
struct sway_transaction *txn = transaction_create();
- arrange_windows(old_parent, txn);
- if (container->parent != old_parent) {
- arrange_windows(container->parent, txn);
+ arrange_windows(old_ws, txn);
+ if (new_ws != old_ws) {
+ arrange_windows(new_ws, txn);
}
transaction_commit(txn);
}