From: Michael Stapelberg Date: Thu, 30 Dec 2010 01:39:14 +0000 (+0100) Subject: Bugfix: Don’t redistribute resize percentage values when closing floating (!) windows... X-Git-Tag: tree-pr2~153 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=f65e4f5b16dc613e03711c5edc27c736c2f943c7;p=i3%2Fi3 Bugfix: Don’t redistribute resize percentage values when closing floating (!) windows (Thanks Merovius) (+testcase) --- diff --git a/src/tree.c b/src/tree.c index f86ae312..baa11ced 100644 --- a/src/tree.c +++ b/src/tree.c @@ -180,7 +180,11 @@ void tree_close(Con *con, bool kill_window, bool dont_kill_parent) { x_con_kill(con); con_detach(con); - con_fix_percent(parent, WINDOW_REMOVE); + if (con->type != CT_FLOATING_CON) { + /* If the container is *not* floating, we might need to re-distribute + * percentage values for the resized containers. */ + con_fix_percent(parent, WINDOW_REMOVE); + } if (con_is_floating(con)) { DLOG("Container was floating, killing floating container\n"); diff --git a/testcases/t/44-regress-floating-resize.t b/testcases/t/44-regress-floating-resize.t new file mode 100644 index 00000000..d7102cec --- /dev/null +++ b/testcases/t/44-regress-floating-resize.t @@ -0,0 +1,38 @@ +#!perl +# vim:ts=4:sw=4:expandtab +# +# Regression: when resizing two containers on a workspace, opening a floating +# client, then closing it again, i3 will re-distribute the space on the +# workspace as if a tiling container was closed, leading to the containers +# taking much more space than they possibly could. +# +use i3test tests => 1; +use X11::XCB qw(:all); +use Time::HiRes qw(sleep); +use List::Util qw(sum); + +my $tmp = get_unused_workspace(); +cmd "workspace $tmp"; + +cmd 'exec /usr/bin/urxvt'; +sleep 0.5; +cmd 'exec /usr/bin/urxvt'; +sleep 0.5; +my ($nodes, $focus) = get_ws_content($tmp); +my $old_sum = sum map { $_->{rect}->{width} } @{$nodes}; +#cmd 'open'; +cmd 'resize grow left 10 px or 25 ppt'; +cmd 'split v'; +#cmd 'open'; +cmd 'exec /usr/bin/urxvt'; +sleep 0.5; +cmd 'mode toggle'; +sleep 0.5; +cmd 'kill'; + +sleep 0.5; + +($nodes, $focus) = get_ws_content($tmp); +my $new_sum = sum map { $_->{rect}->{width} } @{$nodes}; + +is($old_sum, $new_sum, 'combined container width is still equal');