aboutsummaryrefslogtreecommitdiffstats
path: root/sway/tree/view.c
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-08-03 17:55:58 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-08-03 17:55:58 +1000
commit854c5fbec872ee093cc2728558f69f7f567f3136 (patch)
tree92072d967e15605859c723e9c43b1c8457137ccb /sway/tree/view.c
parentMerge pull request #2408 from ianyfan/exit-nag (diff)
downloadsway-854c5fbec872ee093cc2728558f69f7f567f3136.tar.gz
sway-854c5fbec872ee093cc2728558f69f7f567f3136.tar.zst
sway-854c5fbec872ee093cc2728558f69f7f567f3136.zip
Fix crash when fullscreen view closes on inactive workspace
When a view unmaps, normally the surviving ancestor (ie. after reaping) needs to be arranged. When a fullscreen view unmaps, it arranges the workspace rather than the surviving ancestor, but didn't handle cases where the workspace itself was reaped. This happens if the workspace is not currently shown and the fullscreen view was the last container on that workspace. This commit rewrites this part of view_unmap so it's more readable, and fixes the crash by not arranging the workspace if it's been reaped. Note that it no longer arranges the output under any circumstance - this wasn't required anyway.
Diffstat (limited to 'sway/tree/view.c')
-rw-r--r--sway/tree/view.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/sway/tree/view.c b/sway/tree/view.c
index 97318daa..78baa705 100644
--- a/sway/tree/view.c
+++ b/sway/tree/view.c
@@ -592,19 +592,18 @@ void view_unmap(struct sway_view *view) {
592 view->urgent_timer = NULL; 592 view->urgent_timer = NULL;
593 } 593 }
594 594
595 struct sway_container *ws = container_parent(view->swayc, C_WORKSPACE); 595 bool was_fullscreen = view->swayc->is_fullscreen;
596 596 struct sway_container *surviving_ancestor = container_destroy(view->swayc);
597 struct sway_container *parent; 597
598 if (container_is_fullscreen_or_child(view->swayc)) { 598 // If the workspace wasn't reaped
599 parent = container_destroy(view->swayc); 599 if (surviving_ancestor->type >= C_WORKSPACE) {
600 arrange_windows(ws->parent); 600 struct sway_container *ws = surviving_ancestor->type == C_WORKSPACE ?
601 } else { 601 surviving_ancestor :
602 parent = container_destroy(view->swayc); 602 container_parent(surviving_ancestor, C_WORKSPACE);
603 arrange_windows(parent); 603 arrange_windows(was_fullscreen ? ws : surviving_ancestor);
604 }
605 if (parent->type >= C_WORKSPACE) { // if the workspace still exists
606 workspace_detect_urgent(ws); 604 workspace_detect_urgent(ws);
607 } 605 }
606
608 transaction_commit_dirty(); 607 transaction_commit_dirty();
609 view->surface = NULL; 608 view->surface = NULL;
610} 609}