From: Michael Stapelberg Date: Mon, 29 Nov 2010 10:24:12 +0000 (+0100) Subject: Bugfix: Transfer 'percent' factor when splitting, add testcase for resizing X-Git-Tag: tree-pr1~14 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=b0068de3d7165ca5db1608e18345513cbc74e460;p=i3%2Fi3 Bugfix: Transfer 'percent' factor when splitting, add testcase for resizing --- diff --git a/src/tree.c b/src/tree.c index f24b91a1..f1b521e8 100644 --- a/src/tree.c +++ b/src/tree.c @@ -267,7 +267,11 @@ void tree_split(Con *con, orientation_t orientation) { new->parent = parent; new->orientation = orientation; - /* 3: add it as a child to the new Con */ + /* 3: swap 'percent' (resize factor) */ + new->percent = con->percent; + con->percent = 0.0; + + /* 4: add it as a child to the new Con */ con_attach(con, new, false); } diff --git a/testcases/t/41-resize.t b/testcases/t/41-resize.t new file mode 100644 index 00000000..050b92a6 --- /dev/null +++ b/testcases/t/41-resize.t @@ -0,0 +1,49 @@ +#!perl +# vim:ts=4:sw=4:expandtab +# Tests resizing tiling containers +use i3test tests => 6; +use X11::XCB qw(:all); +use Time::HiRes qw(sleep); + +BEGIN { + use_ok('X11::XCB::Window'); +} + +my $x = X11::XCB::Connection->new; + +my $tmp = get_unused_workspace(); +cmd "workspace $tmp"; + +cmd 'split v'; + +my $top = open_standard_window($x); +sleep 0.25; +my $bottom = open_standard_window($x); +sleep 0.25; + +diag("top = " . $top->id . ", bottom = " . $bottom->id); + +is($x->input_focus, $bottom->id, 'Bottom window focused'); + +############################################################ +# resize +############################################################ + +cmd 'resize grow up 10 px or 25 ppt'; + +my ($nodes, $focus) = get_ws_content($tmp); + +is($nodes->[0]->{percent}, 0.25, 'top window got only 25%'); +is($nodes->[1]->{percent}, 0.75, 'bottom window got 75%'); + + +############################################################ +# split and check if the 'percent' factor is still correct +############################################################ + +cmd 'split h'; + +($nodes, $focus) = get_ws_content($tmp); + +is($nodes->[0]->{percent}, 0.25, 'top window got only 25%'); +is($nodes->[1]->{percent}, 0.75, 'bottom window got 75%');