2 # vim:ts=4:sw=4:expandtab
3 # Tests resizing tiling containers
8 use_ok('X11::XCB::Window');
11 my $x = X11::XCB::Connection->new;
13 my $tmp = fresh_workspace;
17 my $top = open_window($x);
18 my $bottom = open_window($x);
22 diag("top = " . $top->id . ", bottom = " . $bottom->id);
24 is($x->input_focus, $bottom->id, 'Bottom window focused');
26 ############################################################
28 ############################################################
30 cmd 'resize grow up 10 px or 25 ppt';
32 my ($nodes, $focus) = get_ws_content($tmp);
34 is($nodes->[0]->{percent}, 0.25, 'top window got only 25%');
35 is($nodes->[1]->{percent}, 0.75, 'bottom window got 75%');
38 ############################################################
39 # split and check if the 'percent' factor is still correct
40 ############################################################
44 ($nodes, $focus) = get_ws_content($tmp);
46 is($nodes->[0]->{percent}, 0.25, 'top window got only 25%');
47 is($nodes->[1]->{percent}, 0.75, 'bottom window got 75%');
49 ############################################################
50 # checks that resizing within stacked/tabbed cons works
51 ############################################################
53 $tmp = fresh_workspace;
57 $top = open_window($x);
58 $bottom = open_window($x);
63 ($nodes, $focus) = get_ws_content($tmp);
64 is($nodes->[0]->{percent}, 0.5, 'top window got 50%');
65 is($nodes->[1]->{percent}, 0.5, 'bottom window got 50%');
67 cmd 'resize grow up 10 px or 25 ppt';
69 ($nodes, $focus) = get_ws_content($tmp);
70 is($nodes->[0]->{percent}, 0.25, 'top window got 25%');
71 is($nodes->[1]->{percent}, 0.75, 'bottom window got 75%');
73 ############################################################
74 # Checks that resizing in the parent's parent's orientation works.
75 # Take for example a horizontal workspace with one window on the left side and
76 # a v-split container with two windows on the right side. Focus is on the
77 # bottom right window, use 'resize left'.
78 ############################################################
80 $tmp = fresh_workspace;
82 my $left = open_window;
83 my $right = open_window;
88 $bottom = open_window;
90 ($nodes, $focus) = get_ws_content($tmp);
91 is($nodes->[0]->{percent}, 0.5, 'left window got 50%');
92 is($nodes->[1]->{percent}, 0.5, 'right window got 50%');
94 cmd 'resize grow left 10 px or 25 ppt';
96 ($nodes, $focus) = get_ws_content($tmp);
97 is($nodes->[0]->{percent}, 0.25, 'left window got 25%');
98 is($nodes->[1]->{percent}, 0.75, 'right window got 75%');
100 ############################################################
101 # checks that resizing floating windows works
102 ############################################################
104 $tmp = fresh_workspace;
106 $top = open_window($x);
108 cmd 'floating enable';
110 my @content = @{get_ws($tmp)->{floating_nodes}};
111 cmp_ok(@content, '==', 1, 'one floating node on this ws');
114 my $oldrect = $content[0]->{rect};
116 cmd 'resize grow up 10 px or 25 ppt';
118 @content = @{get_ws($tmp)->{floating_nodes}};
119 cmp_ok($content[0]->{rect}->{y}, '<', $oldrect->{y}, 'y smaller than before');
120 cmp_ok($content[0]->{rect}->{y}, '==', $oldrect->{y} - 10, 'y exactly 10 px smaller');
121 cmp_ok($content[0]->{rect}->{x}, '==', $oldrect->{x}, 'x untouched');
122 cmp_ok($content[0]->{rect}->{height}, '>', $oldrect->{height}, 'height bigger than before');
123 cmp_ok($content[0]->{rect}->{height}, '==', $oldrect->{height} + 10, 'height exactly 10 px higher');
124 cmp_ok($content[0]->{rect}->{width}, '==', $oldrect->{width}, 'x untouched');
126 # up, but with a different amount of px
127 $oldrect = $content[0]->{rect};
129 cmd 'resize grow up 12 px or 25 ppt';
131 @content = @{get_ws($tmp)->{floating_nodes}};
132 cmp_ok($content[0]->{rect}->{y}, '<', $oldrect->{y}, 'y smaller than before');
133 cmp_ok($content[0]->{rect}->{y}, '==', $oldrect->{y} - 12, 'y exactly 10 px smaller');
134 cmp_ok($content[0]->{rect}->{x}, '==', $oldrect->{x}, 'x untouched');
135 cmp_ok($content[0]->{rect}->{height}, '>', $oldrect->{height}, 'height bigger than before');
136 cmp_ok($content[0]->{rect}->{height}, '==', $oldrect->{height} + 12, 'height exactly 10 px higher');
137 cmp_ok($content[0]->{rect}->{width}, '==', $oldrect->{width}, 'x untouched');
140 $oldrect = $content[0]->{rect};
142 cmd 'resize grow left 10 px or 25 ppt';
144 @content = @{get_ws($tmp)->{floating_nodes}};
145 cmp_ok($content[0]->{rect}->{x}, '<', $oldrect->{x}, 'x smaller than before');
146 cmp_ok($content[0]->{rect}->{width}, '>', $oldrect->{width}, 'width bigger than before');
149 $oldrect = $content[0]->{rect};
151 cmd 'resize grow right 10 px or 25 ppt';
153 @content = @{get_ws($tmp)->{floating_nodes}};
154 cmp_ok($content[0]->{rect}->{x}, '==', $oldrect->{x}, 'x the same as before');
155 cmp_ok($content[0]->{rect}->{y}, '==', $oldrect->{y}, 'y the same as before');
156 cmp_ok($content[0]->{rect}->{width}, '>', $oldrect->{width}, 'width bigger than before');
157 cmp_ok($content[0]->{rect}->{height}, '==', $oldrect->{height}, 'height the same as before');
160 $oldrect = $content[0]->{rect};
162 cmd 'resize grow down 10 px or 25 ppt';
164 @content = @{get_ws($tmp)->{floating_nodes}};
165 cmp_ok($content[0]->{rect}->{x}, '==', $oldrect->{x}, 'x the same as before');
166 cmp_ok($content[0]->{rect}->{y}, '==', $oldrect->{y}, 'y the same as before');
167 cmp_ok($content[0]->{rect}->{height}, '>', $oldrect->{height}, 'height bigger than before');
168 cmp_ok($content[0]->{rect}->{width}, '==', $oldrect->{width}, 'width the same as before');