From f65e4f5b16dc613e03711c5edc27c736c2f943c7 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Thu, 30 Dec 2010 02:39:14 +0100 Subject: [PATCH] =?UTF-8?q?Bugfix:=20Don=E2=80=99t=20redistribute=20resize?= =?UTF-8?q?=20percentage=20values=20when=20closing=20floating=20(!)=20wind?= =?UTF-8?q?ows=20(Thanks=20Merovius)=20(+testcase)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/tree.c | 6 +++- testcases/t/44-regress-floating-resize.t | 38 ++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 testcases/t/44-regress-floating-resize.t 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');