From c028f0cb173ebc4c7033c758c7f942adfbc224af Mon Sep 17 00:00:00 2001 From: Dan Elkouby Date: Sun, 30 Jul 2017 18:49:42 +0300 Subject: [PATCH 1/3] Create a new split container when switching a workspace container to split layout The behavior before 52ce8c8 was to do it regardless of what layout we're switching to. Fixes #2846 --- src/con.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/con.c b/src/con.c index b6b0da2c..88d1e744 100644 --- a/src/con.c +++ b/src/con.c @@ -1756,7 +1756,7 @@ void con_set_layout(Con *con, layout_t layout) { con->workspace_layout = ws_layout; DLOG("Setting layout to %d\n", layout); con->layout = layout; - } else if (layout == L_STACKED || layout == L_TABBED) { + } else if (layout == L_STACKED || layout == L_TABBED || layout == L_SPLITV || layout == L_SPLITH) { DLOG("Creating new split container\n"); /* 1: create a new split container */ Con *new = con_new(NULL, NULL); From a34a0048a1a9c009e23162f3039254768fc2fa8e Mon Sep 17 00:00:00 2001 From: hwangcc23 Date: Sun, 6 Aug 2017 23:08:05 +0800 Subject: [PATCH 2/3] Add regression tests for #2846 1). Add one regression test in 167-workspace_layout.t: - Get a fresh workspace - Set the layout to something - Create windows - Try to switch to another layout - Check if successful - Repeat for all 12 possible transitions 2). Add another regression test in 167-workspace_layout.t: - Check that the command 'layout toggle split' works regardless of what layout we're using --- testcases/t/167-workspace_layout.t | 67 ++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/testcases/t/167-workspace_layout.t b/testcases/t/167-workspace_layout.t index d983eb85..597d545e 100644 --- a/testcases/t/167-workspace_layout.t +++ b/testcases/t/167-workspace_layout.t @@ -375,7 +375,74 @@ ok(@content == 2, 'two containers opened'); isnt($content[0]->{layout}, 'tabbed', 'layout not tabbed'); isnt($content[1]->{layout}, 'tabbed', 'layout not tabbed'); +exit_gracefully($pid); + +##################################################################### +# 16: Check that the command 'layout toggle split' works regardless +# of what layout we're using. +##################################################################### + +$config = <{layout}, 'splitv', 'layout toggles to splitv'); + } else { + is($content[0]->{layout}, 'splith', 'layout toggles to splith'); + } + + cmd '[id="' . $first->id . '"] kill'; + cmd '[id="' . $second->id . '"] kill'; + sync_with_i3; +} exit_gracefully($pid); +##################################################################### +# 17: Check about setting a new layout. +##################################################################### + +$config = <{layout}, $second_layout, 'layout changes to ' . $second_layout); + + cmd '[id="' . $first->id . '"] kill'; + cmd '[id="' . $second->id . '"] kill'; + sync_with_i3; + } +} + done_testing; From 26014ca1a22c1b862c782f4dfa3d40a5ab629627 Mon Sep 17 00:00:00 2001 From: Dan Elkouby Date: Thu, 12 Oct 2017 23:44:25 +0300 Subject: [PATCH 3/3] Default to L_SPLITH with toggle split when last_split_layout hasn't been initialized --- src/con.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/con.c b/src/con.c index 88d1e744..1de91d00 100644 --- a/src/con.c +++ b/src/con.c @@ -1848,6 +1848,10 @@ void con_toggle_layout(Con *con, const char *toggle_mode) { * change to the opposite split layout. */ if (parent->layout != L_SPLITH && parent->layout != L_SPLITV) { layout = parent->last_split_layout; + /* In case last_split_layout was not initialized… */ + if (layout == L_DEFAULT) { + layout = L_SPLITH; + } } else { layout = (parent->layout == L_SPLITH) ? L_SPLITV : L_SPLITH; }