2 # vim:ts=4:sw=4:expandtab
3 # Tests resizing tiling containers
6 my $tmp = fresh_workspace;
10 my $top = open_window;
11 my $bottom = open_window;
13 diag("top = " . $top->id . ", bottom = " . $bottom->id);
15 is($x->input_focus, $bottom->id, 'Bottom window focused');
17 ############################################################
19 ############################################################
21 cmd 'resize grow up 10 px or 25 ppt';
23 my ($nodes, $focus) = get_ws_content($tmp);
25 ok(cmp_float($nodes->[0]->{percent}, 0.25), 'top window got only 25%');
26 ok(cmp_float($nodes->[1]->{percent}, 0.75), 'bottom window got 75%');
29 ############################################################
30 # split and check if the 'percent' factor is still correct
31 ############################################################
35 ($nodes, $focus) = get_ws_content($tmp);
37 ok(cmp_float($nodes->[0]->{percent}, 0.25), 'top window got only 25%');
38 ok(cmp_float($nodes->[1]->{percent}, 0.75), 'bottom window got 75%');
40 ############################################################
41 # checks that resizing within stacked/tabbed cons works
42 ############################################################
44 $tmp = fresh_workspace;
49 $bottom = open_window;
54 ($nodes, $focus) = get_ws_content($tmp);
55 ok(cmp_float($nodes->[0]->{percent}, 0.5), 'top window got 50%');
56 ok(cmp_float($nodes->[1]->{percent}, 0.5), 'bottom window got 50%');
58 cmd 'resize grow up 10 px or 25 ppt';
60 ($nodes, $focus) = get_ws_content($tmp);
61 ok(cmp_float($nodes->[0]->{percent}, 0.25), 'top window got 25%');
62 ok(cmp_float($nodes->[1]->{percent}, 0.75), 'bottom window got 75%');
64 ############################################################
65 # Checks that resizing in the parent's parent's orientation works.
66 # Take for example a horizontal workspace with one window on the left side and
67 # a v-split container with two windows on the right side. Focus is on the
68 # bottom right window, use 'resize left'.
69 ############################################################
71 $tmp = fresh_workspace;
73 my $left = open_window;
74 my $right = open_window;
79 $bottom = open_window;
81 ($nodes, $focus) = get_ws_content($tmp);
82 ok(cmp_float($nodes->[0]->{percent}, 0.5), 'left window got 50%');
83 ok(cmp_float($nodes->[1]->{percent}, 0.5), 'right window got 50%');
85 cmd 'resize grow left 10 px or 25 ppt';
87 ($nodes, $focus) = get_ws_content($tmp);
88 ok(cmp_float($nodes->[0]->{percent}, 0.25), 'left window got 25%');
89 ok(cmp_float($nodes->[1]->{percent}, 0.75), 'right window got 75%');
91 ################################################################################
92 # Check that the resize grow/shrink width/height syntax works.
93 ################################################################################
96 $tmp = fresh_workspace;
101 cmd 'resize grow width 10 px or 25 ppt';
103 ($nodes, $focus) = get_ws_content($tmp);
104 ok(cmp_float($nodes->[0]->{percent}, 0.25), 'left window got 25%');
105 ok(cmp_float($nodes->[1]->{percent}, 0.75), 'right window got 75%');
107 # Now test it with four windows
108 $tmp = fresh_workspace;
110 open_window for (1..4);
112 cmd 'resize grow width 10 px or 25 ppt';
114 ($nodes, $focus) = get_ws_content($tmp);
115 ok(cmp_float($nodes->[0]->{percent}, 0.166666666666667), 'first window got 16%');
116 ok(cmp_float($nodes->[1]->{percent}, 0.166666666666667), 'second window got 16%');
117 ok(cmp_float($nodes->[2]->{percent}, 0.166666666666667), 'third window got 16%');
118 ok(cmp_float($nodes->[3]->{percent}, 0.50), 'fourth window got 50%');
120 # height should be a no-op in this situation
121 cmd 'resize grow height 10 px or 25 ppt';
123 ($nodes, $focus) = get_ws_content($tmp);
124 ok(cmp_float($nodes->[0]->{percent}, 0.166666666666667), 'first window got 16%');
125 ok(cmp_float($nodes->[1]->{percent}, 0.166666666666667), 'second window got 16%');
126 ok(cmp_float($nodes->[2]->{percent}, 0.166666666666667), 'third window got 16%');
127 ok(cmp_float($nodes->[3]->{percent}, 0.50), 'fourth window got 50%');
130 ############################################################
131 # checks that resizing floating windows works
132 ############################################################
134 $tmp = fresh_workspace;
138 cmd 'floating enable';
140 my @content = @{get_ws($tmp)->{floating_nodes}};
141 cmp_ok(@content, '==', 1, 'one floating node on this ws');
144 my $oldrect = $content[0]->{rect};
146 cmd 'resize grow up 10 px or 25 ppt';
148 @content = @{get_ws($tmp)->{floating_nodes}};
149 cmp_ok($content[0]->{rect}->{y}, '<', $oldrect->{y}, 'y smaller than before');
150 cmp_ok($content[0]->{rect}->{y}, '==', $oldrect->{y} - 10, 'y exactly 10 px smaller');
151 cmp_ok($content[0]->{rect}->{x}, '==', $oldrect->{x}, 'x untouched');
152 cmp_ok($content[0]->{rect}->{height}, '>', $oldrect->{height}, 'height bigger than before');
153 cmp_ok($content[0]->{rect}->{height}, '==', $oldrect->{height} + 10, 'height exactly 10 px higher');
154 cmp_ok($content[0]->{rect}->{width}, '==', $oldrect->{width}, 'x untouched');
156 # up, but with a different amount of px
157 $oldrect = $content[0]->{rect};
159 cmd 'resize grow up 12 px or 25 ppt';
161 @content = @{get_ws($tmp)->{floating_nodes}};
162 cmp_ok($content[0]->{rect}->{y}, '<', $oldrect->{y}, 'y smaller than before');
163 cmp_ok($content[0]->{rect}->{y}, '==', $oldrect->{y} - 12, 'y exactly 10 px smaller');
164 cmp_ok($content[0]->{rect}->{x}, '==', $oldrect->{x}, 'x untouched');
165 cmp_ok($content[0]->{rect}->{height}, '>', $oldrect->{height}, 'height bigger than before');
166 cmp_ok($content[0]->{rect}->{height}, '==', $oldrect->{height} + 12, 'height exactly 10 px higher');
167 cmp_ok($content[0]->{rect}->{width}, '==', $oldrect->{width}, 'x untouched');
170 $oldrect = $content[0]->{rect};
172 cmd 'resize grow left 10 px or 25 ppt';
174 @content = @{get_ws($tmp)->{floating_nodes}};
175 cmp_ok($content[0]->{rect}->{x}, '<', $oldrect->{x}, 'x smaller than before');
176 cmp_ok($content[0]->{rect}->{width}, '>', $oldrect->{width}, 'width bigger than before');
179 $oldrect = $content[0]->{rect};
181 cmd 'resize grow right 10 px or 25 ppt';
183 @content = @{get_ws($tmp)->{floating_nodes}};
184 cmp_ok($content[0]->{rect}->{x}, '==', $oldrect->{x}, 'x the same as before');
185 cmp_ok($content[0]->{rect}->{y}, '==', $oldrect->{y}, 'y the same as before');
186 cmp_ok($content[0]->{rect}->{width}, '>', $oldrect->{width}, 'width bigger than before');
187 cmp_ok($content[0]->{rect}->{height}, '==', $oldrect->{height}, 'height the same as before');
190 $oldrect = $content[0]->{rect};
192 cmd 'resize grow down 10 px or 25 ppt';
194 @content = @{get_ws($tmp)->{floating_nodes}};
195 cmp_ok($content[0]->{rect}->{x}, '==', $oldrect->{x}, 'x the same as before');
196 cmp_ok($content[0]->{rect}->{y}, '==', $oldrect->{y}, 'y the same as before');
197 cmp_ok($content[0]->{rect}->{height}, '>', $oldrect->{height}, 'height bigger than before');
198 cmp_ok($content[0]->{rect}->{width}, '==', $oldrect->{width}, 'width the same as before');