From: Michael Stapelberg Date: Thu, 30 Jun 2011 23:10:43 +0000 (+0200) Subject: Bugfix: Correctly revert floating focus when killing the last floating window (+test) X-Git-Tag: tree-pr4~72 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=23d4917e435d94e8b7a30f58740fdd5b8dc82fec;p=i3%2Fi3 Bugfix: Correctly revert floating focus when killing the last floating window (+test) --- diff --git a/src/con.c b/src/con.c index 185cbd3f..7ce782bc 100644 --- a/src/con.c +++ b/src/con.c @@ -646,7 +646,12 @@ Con *con_next_focused(Con *con) { if (con->type == CT_FLOATING_CON) { DLOG("selecting next for CT_FLOATING_CON\n"); next = TAILQ_NEXT(con, floating_windows); - if (next == TAILQ_END(&(parent->floating_head))) { + DLOG("next = %p\n", next); + if (!next) { + next = TAILQ_PREV(con, floating_head, floating_windows); + DLOG("using prev, next = %p\n", next); + } + if (!next) { Con *ws = con_get_workspace(con); next = ws; DLOG("no more floating containers for next = %p, restoring workspace focus\n", next); diff --git a/testcases/t/35-floating-focus.t b/testcases/t/35-floating-focus.t index d0f8814f..7d5cf53b 100644 --- a/testcases/t/35-floating-focus.t +++ b/testcases/t/35-floating-focus.t @@ -59,9 +59,9 @@ is($x->input_focus, $second->id, 'second con still focused after killing third') $tmp = fresh_workspace; -$first = open_standard_window($x); # window 5 -$second = open_standard_window($x); # window 6 -my $third = open_standard_window($x); # window 7 +$first = open_standard_window($x, '#ff0000'); # window 5 +$second = open_standard_window($x, '#00ff00'); # window 6 +my $third = open_standard_window($x, '#0000ff'); # window 7 is($x->input_focus, $third->id, 'last container focused'); @@ -87,4 +87,42 @@ sleep 0.25; is($x->input_focus, $first->id, 'first con focused after killing all floating cons'); +############################################################################# +# 4: same test as 3, but with another split con +############################################################################# + +$tmp = fresh_workspace; + +$first = open_standard_window($x, '#ff0000'); # window 5 +cmd 'split v'; +cmd 'layout stacked'; +$second = open_standard_window($x, '#00ff00'); # window 6 +$third = open_standard_window($x, '#0000ff'); # window 7 + +is($x->input_focus, $third->id, 'last container focused'); + +cmd 'floating enable'; + +cmd '[id="' . $second->id . '"] focus'; + +is($x->input_focus, $second->id, 'second con focused'); + +cmd 'floating enable'; + +sleep 0.5; + +# now kill the second one. focus should fall back to the third one, which is +# also floating +cmd 'kill'; + +sleep 0.25; + +is($x->input_focus, $third->id, 'second con focused'); + +cmd 'kill'; + +sleep 0.25; + +is($x->input_focus, $first->id, 'first con focused after killing all floating cons'); + done_testing;