commit 854c5fbec872ee093cc2728558f69f7f567f3136
parent 5ac3509d546ee2e585ecb58aeea94ff9f3e8259d
Author: Ryan Dwyer <ryandwyer1@gmail.com>
Date: Fri, 3 Aug 2018 17:55:58 +1000
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:
1 file changed, 10 insertions(+), 11 deletions(-)
diff --git a/sway/tree/view.c b/sway/tree/view.c
@@ -592,19 +592,18 @@ void view_unmap(struct sway_view *view) {
view->urgent_timer = NULL;
}
- struct sway_container *ws = container_parent(view->swayc, C_WORKSPACE);
-
- struct sway_container *parent;
- if (container_is_fullscreen_or_child(view->swayc)) {
- parent = container_destroy(view->swayc);
- arrange_windows(ws->parent);
- } else {
- parent = container_destroy(view->swayc);
- arrange_windows(parent);
- }
- if (parent->type >= C_WORKSPACE) { // if the workspace still exists
+ bool was_fullscreen = view->swayc->is_fullscreen;
+ struct sway_container *surviving_ancestor = container_destroy(view->swayc);
+
+ // If the workspace wasn't reaped
+ if (surviving_ancestor->type >= C_WORKSPACE) {
+ struct sway_container *ws = surviving_ancestor->type == C_WORKSPACE ?
+ surviving_ancestor :
+ container_parent(surviving_ancestor, C_WORKSPACE);
+ arrange_windows(was_fullscreen ? ws : surviving_ancestor);
workspace_detect_urgent(ws);
}
+
transaction_commit_dirty();
view->surface = NULL;
}