]> git.sur5r.net Git - i3/i3/commitdiff
Merge pull request #2849 from Streetwalrus/next
authorIngo Bürk <admin@airblader.de>
Sun, 15 Oct 2017 20:23:40 +0000 (22:23 +0200)
committerGitHub <noreply@github.com>
Sun, 15 Oct 2017 20:23:40 +0000 (22:23 +0200)
Create a new split container when switching a workspace container to split layout

src/con.c
testcases/t/167-workspace_layout.t

index b6b0da2c6f48318b283e3a94479f172797317065..1de91d00861c3e11736f6b2682914c70b5c83407 100644 (file)
--- 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);
@@ -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;
                 }
index d983eb8565de3d77b5ba9ffba1544e145122aaaa..597d545eb8c903d806643503bb12d58e11120725 100644 (file)
@@ -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 = <<EOT;
+# i3 config file (v4)
+font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
+workspace_layout default
+EOT
+
+$pid = launch_with_config($config);
+
+$tmp = fresh_workspace;
+
+my @layouts = ('splith', 'splitv', 'tabbed', 'stacked');
+my $first_layout;
+
+foreach $first_layout (@layouts) {
+    cmd 'layout ' . $first_layout;
+    $first = open_window;
+    $second = open_window;
+    cmd 'layout toggle split';
+    @content = @{get_ws_content($tmp)};
+    if ($first_layout eq 'splith') {
+        is($content[0]->{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 = <<EOT;
+# i3 config file (v4)
+font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
+workspace_layout default
+EOT
+
+$pid = launch_with_config($config);
+
+$tmp = fresh_workspace;
+
+my $second_layout;
+
+foreach $first_layout (@layouts) {
+    foreach $second_layout (@layouts) {
+        cmd 'layout ' . $first_layout;
+        $first = open_window;
+        $second = open_window;
+        cmd 'layout ' . $second_layout;
+        @content = @{get_ws_content($tmp)};
+        is($content[0]->{layout}, $second_layout, 'layout changes to ' . $second_layout);
+
+        cmd '[id="' . $first->id . '"] kill';
+        cmd '[id="' . $second->id . '"] kill';
+        sync_with_i3;
+    }
+}
+
 done_testing;