diff options
author | Drew DeVault <sir@cmpwn.com> | 2018-10-15 15:35:50 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-15 15:35:50 +0200 |
commit | 97b9452171f2532831a876167fe93c71541d644d (patch) | |
tree | 76bf683cbff6e29285059e2ebd4e60192b6ef938 /sway/commands/swap.c | |
parent | 56c388b51076c3d96363e6afb62d0138cd3dce36 (diff) | |
parent | fe803b89a7ecee7f737ad82bfe0bab441c163156 (diff) |
Merge pull request #2835 from RyanDwyer/swap-crash
Fix crash in swap command
Diffstat (limited to 'sway/commands/swap.c')
-rw-r--r-- | sway/commands/swap.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/sway/commands/swap.c b/sway/commands/swap.c index e7f9cbea..d8ffe78c 100644 --- a/sway/commands/swap.c +++ b/sway/commands/swap.c @@ -22,6 +22,7 @@ static void swap_places(struct sway_container *con1, temp->width = con1->width; temp->height = con1->height; temp->parent = con1->parent; + temp->workspace = con1->workspace; con1->x = con2->x; con1->y = con2->y; @@ -34,8 +35,18 @@ static void swap_places(struct sway_container *con1, con2->height = temp->height; int temp_index = container_sibling_index(con1); - container_insert_child(con2->parent, con1, container_sibling_index(con2)); - container_insert_child(temp->parent, con2, temp_index); + if (con2->parent) { + container_insert_child(con2->parent, con1, + container_sibling_index(con2)); + } else { + workspace_insert_tiling(con2->workspace, con1, + container_sibling_index(con2)); + } + if (temp->parent) { + container_insert_child(temp->parent, con2, temp_index); + } else { + workspace_insert_tiling(temp->workspace, con2, temp_index); + } free(temp); } |