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 is($nodes->[0]->{percent}, 0.25, 'top window got only 25%');
26 is($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 is($nodes->[0]->{percent}, 0.25, 'top window got only 25%');
38 is($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 is($nodes->[0]->{percent}, 0.5, 'top window got 50%');
56 is($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 is($nodes->[0]->{percent}, 0.25, 'top window got 25%');
62 is($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 is($nodes->[0]->{percent}, 0.5, 'left window got 50%');
83 is($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 is($nodes->[0]->{percent}, 0.25, 'left window got 25%');
89 is($nodes->[1]->{percent}, 0.75, 'right window got 75%');
91 ############################################################
92 # checks that resizing floating windows works
93 ############################################################
95 $tmp = fresh_workspace;
99 cmd 'floating enable';
101 my @content = @{get_ws($tmp)->{floating_nodes}};
102 cmp_ok(@content, '==', 1, 'one floating node on this ws');
105 my $oldrect = $content[0]->{rect};
107 cmd 'resize grow up 10 px or 25 ppt';
109 @content = @{get_ws($tmp)->{floating_nodes}};
110 cmp_ok($content[0]->{rect}->{y}, '<', $oldrect->{y}, 'y smaller than before');
111 cmp_ok($content[0]->{rect}->{y}, '==', $oldrect->{y} - 10, 'y exactly 10 px smaller');
112 cmp_ok($content[0]->{rect}->{x}, '==', $oldrect->{x}, 'x untouched');
113 cmp_ok($content[0]->{rect}->{height}, '>', $oldrect->{height}, 'height bigger than before');
114 cmp_ok($content[0]->{rect}->{height}, '==', $oldrect->{height} + 10, 'height exactly 10 px higher');
115 cmp_ok($content[0]->{rect}->{width}, '==', $oldrect->{width}, 'x untouched');
117 # up, but with a different amount of px
118 $oldrect = $content[0]->{rect};
120 cmd 'resize grow up 12 px or 25 ppt';
122 @content = @{get_ws($tmp)->{floating_nodes}};
123 cmp_ok($content[0]->{rect}->{y}, '<', $oldrect->{y}, 'y smaller than before');
124 cmp_ok($content[0]->{rect}->{y}, '==', $oldrect->{y} - 12, 'y exactly 10 px smaller');
125 cmp_ok($content[0]->{rect}->{x}, '==', $oldrect->{x}, 'x untouched');
126 cmp_ok($content[0]->{rect}->{height}, '>', $oldrect->{height}, 'height bigger than before');
127 cmp_ok($content[0]->{rect}->{height}, '==', $oldrect->{height} + 12, 'height exactly 10 px higher');
128 cmp_ok($content[0]->{rect}->{width}, '==', $oldrect->{width}, 'x untouched');
131 $oldrect = $content[0]->{rect};
133 cmd 'resize grow left 10 px or 25 ppt';
135 @content = @{get_ws($tmp)->{floating_nodes}};
136 cmp_ok($content[0]->{rect}->{x}, '<', $oldrect->{x}, 'x smaller than before');
137 cmp_ok($content[0]->{rect}->{width}, '>', $oldrect->{width}, 'width bigger than before');
140 $oldrect = $content[0]->{rect};
142 cmd 'resize grow right 10 px or 25 ppt';
144 @content = @{get_ws($tmp)->{floating_nodes}};
145 cmp_ok($content[0]->{rect}->{x}, '==', $oldrect->{x}, 'x the same as before');
146 cmp_ok($content[0]->{rect}->{y}, '==', $oldrect->{y}, 'y the same as before');
147 cmp_ok($content[0]->{rect}->{width}, '>', $oldrect->{width}, 'width bigger than before');
148 cmp_ok($content[0]->{rect}->{height}, '==', $oldrect->{height}, 'height the same as before');
151 $oldrect = $content[0]->{rect};
153 cmd 'resize grow down 10 px or 25 ppt';
155 @content = @{get_ws($tmp)->{floating_nodes}};
156 cmp_ok($content[0]->{rect}->{x}, '==', $oldrect->{x}, 'x the same as before');
157 cmp_ok($content[0]->{rect}->{y}, '==', $oldrect->{y}, 'y the same as before');
158 cmp_ok($content[0]->{rect}->{height}, '>', $oldrect->{height}, 'height bigger than before');
159 cmp_ok($content[0]->{rect}->{width}, '==', $oldrect->{width}, 'width the same as before');