From d644dbff640bb27971bcdbd58fe0ae503e8ab6e4 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Wed, 5 Sep 2012 22:03:45 +0200 Subject: [PATCH] bugfix: forgot to mark split containers as split = true (+test) (Thanks szalik) When the workspace layout (formerly orientation) was forced to change due to a move command, the split container we created was not marked as split = true, which caused tree_flatten() to errnously kill the contents of it and thus one window ended up unmanaged. Also, the logic in tree_flatten() was inverted due to commit de94f6da. fixes #790 --- src/tree.c | 4 ++-- src/workspace.c | 4 +++- testcases/t/197-regression-move-vanish.t | 21 +++++++++++++++++++++ 3 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 testcases/t/197-regression-move-vanish.t diff --git a/src/tree.c b/src/tree.c index 2c1c257e..321bc78a 100644 --- a/src/tree.c +++ b/src/tree.c @@ -617,8 +617,8 @@ void tree_flatten(Con *con) { /* The child must have a different orientation than the con but the same as * the con’s parent to be redundant */ - if (con->split || - child->split || + if (!con->split || + !child->split || con_orientation(con) == con_orientation(child) || con_orientation(child) != con_orientation(parent)) goto recurse; diff --git a/src/workspace.c b/src/workspace.c index 85331181..1749959a 100644 --- a/src/workspace.c +++ b/src/workspace.c @@ -699,6 +699,7 @@ void ws_force_orientation(Con *ws, orientation_t orientation) { /* 1: create a new split container */ Con *split = con_new(NULL, NULL); split->parent = ws; + split->split = true; /* 2: copy layout from workspace */ split->layout = ws->layout; @@ -715,9 +716,10 @@ void ws_force_orientation(Con *ws, orientation_t orientation) { /* 4: switch workspace layout */ ws->layout = (orientation == HORIZ) ? L_SPLITH : L_SPLITV; + DLOG("split->layout = %d, ws->layout = %d\n", split->layout, ws->layout); /* 5: attach the new split container to the workspace */ - DLOG("Attaching new split to ws\n"); + DLOG("Attaching new split (%p) to ws (%p)\n", split, ws); con_attach(split, ws, false); /* 6: fix the percentages */ diff --git a/testcases/t/197-regression-move-vanish.t b/testcases/t/197-regression-move-vanish.t new file mode 100644 index 00000000..41c7b87e --- /dev/null +++ b/testcases/t/197-regression-move-vanish.t @@ -0,0 +1,21 @@ +#!perl +# vim:ts=4:sw=4:expandtab +# Regression test: moving a window to the right out of a splitv container would +# make it vanish. +# Ticket: #790 +# Bug still in: 4.2-277-ga598544 +use i3test; + +my $ws = fresh_workspace; + +my $top = open_window; +cmd 'split v'; +my $bottom = open_window; + +is_num_children($ws, 2, 'two windows on workspace level'); + +cmd 'move right'; + +is_num_children($ws, 2, 'still two windows on workspace level'); + +done_testing;