Bugfix: Correctly change focus after closing floating containers (Thanks litemotiv!)

This commit is contained in:
Michael Stapelberg 2011-01-04 22:40:05 +01:00
parent 0416be18df
commit 1fb9b7c431
1 changed files with 14 additions and 2 deletions

View File

@ -173,6 +173,7 @@ void tree_close(Con *con, bool kill_window, bool dont_kill_parent) {
/* Get the container which is next focused */ /* Get the container which is next focused */
Con *next = con_next_focused(con); Con *next = con_next_focused(con);
DLOG("next = %p, focused = %p\n", next, focused);
DLOG("closing %p, kill_window = %d\n", con, kill_window); DLOG("closing %p, kill_window = %d\n", con, kill_window);
Con *child; Con *child;
@ -211,9 +212,18 @@ void tree_close(Con *con, bool kill_window, bool dont_kill_parent) {
} }
if (con_is_floating(con)) { if (con_is_floating(con)) {
Con *ws = con_get_workspace(con);
DLOG("Container was floating, killing floating container\n"); DLOG("Container was floating, killing floating container\n");
tree_close(parent, false, false); tree_close(parent, false, false);
next = NULL; DLOG("parent container killed\n");
if (con == focused) {
DLOG("This is the focused container, i need to find another one to focus. I start looking at ws = %p\n", ws);
next = con_next_focused(ws);
dont_kill_parent = true;
DLOG("Alright, focusing %p\n", next);
} else {
next = NULL;
}
} }
free(con->name); free(con->name);
@ -222,8 +232,10 @@ void tree_close(Con *con, bool kill_window, bool dont_kill_parent) {
/* in the case of floating windows, we already focused another container /* in the case of floating windows, we already focused another container
* when closing the parent, so we can exit now. */ * when closing the parent, so we can exit now. */
if (!next) if (!next) {
DLOG("No next container, i will just exit now\n");
return; return;
}
if (was_mapped || con == focused) { if (was_mapped || con == focused) {
DLOG("focusing %p / %s\n", next, next->name); DLOG("focusing %p / %s\n", next, next->name);