From: Michael Stapelberg Date: Tue, 4 Jan 2011 21:40:05 +0000 (+0100) Subject: Bugfix: Correctly change focus after closing floating containers (Thanks litemotiv!) X-Git-Tag: tree-pr2~138 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=1fb9b7c43124286c6a3dd4f2f74aded95c4a00e2;p=i3%2Fi3 Bugfix: Correctly change focus after closing floating containers (Thanks litemotiv!) --- diff --git a/src/tree.c b/src/tree.c index d5305d5b..0233a125 100644 --- a/src/tree.c +++ b/src/tree.c @@ -173,6 +173,7 @@ void tree_close(Con *con, bool kill_window, bool dont_kill_parent) { /* Get the container which is next focused */ Con *next = con_next_focused(con); + DLOG("next = %p, focused = %p\n", next, focused); DLOG("closing %p, kill_window = %d\n", con, kill_window); Con *child; @@ -211,9 +212,18 @@ void tree_close(Con *con, bool kill_window, bool dont_kill_parent) { } if (con_is_floating(con)) { + Con *ws = con_get_workspace(con); DLOG("Container was floating, killing floating container\n"); 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); @@ -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 * when closing the parent, so we can exit now. */ - if (!next) + if (!next) { + DLOG("No next container, i will just exit now\n"); return; + } if (was_mapped || con == focused) { DLOG("focusing %p / %s\n", next, next->name);