]> git.sur5r.net Git - i3/i3/commitdiff
Bugfix: Fix 'resize' command in nested containers (Thanks mseed)
authorMichael Stapelberg <michael@stapelberg.de>
Tue, 29 Nov 2011 22:36:40 +0000 (22:36 +0000)
committerMichael Stapelberg <michael@stapelberg.de>
Tue, 29 Nov 2011 22:36:40 +0000 (22:36 +0000)
Fixes: #559
src/cmdparse.y
testcases/t/141-resize.t

index d319bb3f0974e5ac0532be5e531f8201da3da510..092bea2d8ee6f5a9626d8f7ca5c0141c40ff7f30 100644 (file)
@@ -967,6 +967,16 @@ resize:
             while (current->parent->layout == L_STACKED ||
                    current->parent->layout == L_TABBED)
                 current = current->parent;
+
+            /* Then further go up until we find one with the matching orientation. */
+            orientation_t search_orientation =
+                (direction == TOK_LEFT || direction == TOK_RIGHT ? HORIZ : VERT);
+
+            while (current->type != CT_WORKSPACE &&
+                   current->type != CT_FLOATING_CON &&
+                   current->parent->orientation != search_orientation)
+                current = current->parent;
+
             /* get the default percentage */
             int children = con_num_children(current->parent);
             Con *other;
index 8691a044fda77ffd3501e19a633a302a59cc5551..e7424b5842908ff579bd6c9800560640eba9b231 100644 (file)
@@ -70,6 +70,33 @@ cmd 'resize grow up 10 px or 25 ppt';
 is($nodes->[0]->{percent}, 0.25, 'top window got 25%');
 is($nodes->[1]->{percent}, 0.75, 'bottom window got 75%');
 
+############################################################
+# Checks that resizing in the parent's parent's orientation works.
+# Take for example a horizontal workspace with one window on the left side and
+# a v-split container with two windows on the right side. Focus is on the
+# bottom right window, use 'resize left'.
+############################################################
+
+$tmp = fresh_workspace;
+
+my $left = open_window;
+my $right = open_window;
+
+cmd 'split v';
+
+$top = open_window;
+$bottom = open_window;
+
+($nodes, $focus) = get_ws_content($tmp);
+is($nodes->[0]->{percent}, 0.5, 'left window got 50%');
+is($nodes->[1]->{percent}, 0.5, 'right window got 50%');
+
+cmd 'resize grow left 10 px or 25 ppt';
+
+($nodes, $focus) = get_ws_content($tmp);
+is($nodes->[0]->{percent}, 0.25, 'left window got 25%');
+is($nodes->[1]->{percent}, 0.75, 'right window got 75%');
+
 ############################################################
 # checks that resizing floating windows works
 ############################################################