close empty parent containers, add testcase
This commit is contained in:
parent
33572b8c4b
commit
09c6b587d3
|
@ -201,6 +201,15 @@ void tree_close(Con *con, bool kill_window) {
|
||||||
DLOG("focusing %p / %s\n", next, next->name);
|
DLOG("focusing %p / %s\n", next, next->name);
|
||||||
/* TODO: check if the container (or one of its children) was focused */
|
/* TODO: check if the container (or one of its children) was focused */
|
||||||
con_focus(next);
|
con_focus(next);
|
||||||
|
|
||||||
|
/* check if the parent container is empty now and close it */
|
||||||
|
if (parent->type != CT_WORKSPACE &&
|
||||||
|
TAILQ_EMPTY(&(parent->nodes_head))) {
|
||||||
|
DLOG("Closing empty parent container\n");
|
||||||
|
/* TODO: check if this container would swallow any other client and
|
||||||
|
* don’t close it automatically. */
|
||||||
|
tree_close(parent, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
#!perl
|
||||||
|
# vim:ts=4:sw=4:expandtab
|
||||||
|
#
|
||||||
|
# Check if empty split containers are automatically closed.
|
||||||
|
#
|
||||||
|
use i3test tests => 4;
|
||||||
|
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');
|
||||||
|
|
||||||
|
# focus the split container
|
||||||
|
$i3->command('level up')->recv;
|
||||||
|
($nodes, $focus) = get_ws_content($tmp);
|
||||||
|
my $split = $focus->[0];
|
||||||
|
$i3->command('level down')->recv;
|
||||||
|
|
||||||
|
$i3->command('open')->recv;
|
||||||
|
|
||||||
|
($nodes, $focus) = get_ws_content($tmp);
|
||||||
|
my $second = $focus->[0];
|
||||||
|
|
||||||
|
isnt($first, $second, 'different container focused');
|
||||||
|
|
||||||
|
##############################################################
|
||||||
|
# close both windows and see if the split container still exists
|
||||||
|
##############################################################
|
||||||
|
|
||||||
|
$i3->command('kill')->recv;
|
||||||
|
$i3->command('kill')->recv;
|
||||||
|
($nodes, $focus) = get_ws_content($tmp);
|
||||||
|
isnt($nodes->[0]->{id}, $split, 'split container closed');
|
||||||
|
|
||||||
|
diag( "Testing i3, Perl $], $^X" );
|
Loading…
Reference in New Issue