Bugfix: Correctly restore focus after close (and add testcase)
This commit is contained in:
parent
5adcea6b3c
commit
b186446fb7
|
@ -143,8 +143,11 @@ void tree_close(Con *con, bool kill_window) {
|
||||||
next = con_get_workspace(con);
|
next = con_get_workspace(con);
|
||||||
} else {
|
} else {
|
||||||
next = TAILQ_NEXT(con, focused);
|
next = TAILQ_NEXT(con, focused);
|
||||||
if (next == TAILQ_END(&(con->parent->nodes_head)))
|
if (next == TAILQ_END(&(con->parent->nodes_head))) {
|
||||||
next = con->parent;
|
next = con->parent;
|
||||||
|
while (!TAILQ_EMPTY(&(next->focus_head)))
|
||||||
|
next = TAILQ_FIRST(&(next->focus_head));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DLOG("closing %p, kill_window = %d\n", con, kill_window);
|
DLOG("closing %p, kill_window = %d\n", con, kill_window);
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
#!perl
|
||||||
|
# vim:ts=4:sw=4:expandtab
|
||||||
|
#
|
||||||
|
# Check if the focus is correctly restored after closing windows.
|
||||||
|
#
|
||||||
|
use i3test tests => 6;
|
||||||
|
use Time::HiRes qw(sleep);
|
||||||
|
|
||||||
|
my $i3 = i3("/tmp/nestedcons");
|
||||||
|
|
||||||
|
my $tmp = get_unused_workspace();
|
||||||
|
$i3->command("workspace $tmp")->recv;
|
||||||
|
|
||||||
|
ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
|
||||||
|
|
||||||
|
$i3->command('open')->recv;
|
||||||
|
my ($nodes, $focus) = get_ws_content($tmp);
|
||||||
|
my $first = $focus->[0];
|
||||||
|
|
||||||
|
$i3->command('split v')->recv;
|
||||||
|
|
||||||
|
($nodes, $focus) = get_ws_content($tmp);
|
||||||
|
|
||||||
|
is($nodes->[0]->{focused}, 0, 'split container not focused');
|
||||||
|
$i3->command('level up')->recv;
|
||||||
|
($nodes, $focus) = get_ws_content($tmp);
|
||||||
|
is($nodes->[0]->{focused}, 1, 'split container focused after level up');
|
||||||
|
|
||||||
|
$i3->command('open')->recv;
|
||||||
|
|
||||||
|
($nodes, $focus) = get_ws_content($tmp);
|
||||||
|
my $second = $focus->[0];
|
||||||
|
|
||||||
|
isnt($first, $second, 'different container focused');
|
||||||
|
|
||||||
|
##############################################################
|
||||||
|
# see if the focus goes down to $first (not to its split parent)
|
||||||
|
# when closing $second
|
||||||
|
##############################################################
|
||||||
|
|
||||||
|
$i3->command('kill')->recv;
|
||||||
|
# TODO: this testcase sometimes has different outcomes when the
|
||||||
|
# sleep is missing. why?
|
||||||
|
sleep 0.25;
|
||||||
|
($nodes, $focus) = get_ws_content($tmp);
|
||||||
|
is($nodes->[0]->{nodes}->[0]->{id}, $first, 'first container found');
|
||||||
|
is($nodes->[0]->{nodes}->[0]->{focused}, 1, 'first container focused');
|
||||||
|
|
||||||
|
diag( "Testing i3, Perl $], $^X" );
|
Loading…
Reference in New Issue