2 # vim:ts=4:sw=4:expandtab
3 # !NO_I3_INSTANCE! will prevent complete-run.pl from starting i3
7 use X11::XCB::Connection;
10 my $x = X11::XCB::Connection->new;
12 ##############################################################
13 # 1: test the following directive:
14 # for_window [class="borderless"] border none
15 # by first creating a window with a different class (should get
16 # the normal border), then creating a window with the class
17 # "borderless" (should get no border)
18 ##############################################################
22 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
23 for_window [class="borderless"] border none
24 for_window [title="special borderless title"] border none
27 my $process = launch_with_config($config);
29 my $tmp = fresh_workspace;
31 my $window = $x->root->create_child(
32 class => WINDOW_CLASS_INPUT_OUTPUT,
33 rect => [ 0, 0, 30, 30 ],
34 background_color => '#00ff00',
37 $window->name('Border window');
41 my @content = @{get_ws_content($tmp)};
42 cmp_ok(@content, '==', 1, 'one node on this workspace now');
43 is($content[0]->{border}, 'normal', 'normal border');
48 my @content = @{get_ws_content($tmp)};
49 cmp_ok(@content, '==', 0, 'no more nodes');
50 diag('content = '. Dumper(\@content));
52 $window = $x->root->create_child(
53 class => WINDOW_CLASS_INPUT_OUTPUT,
54 rect => [ 0, 0, 30, 30 ],
55 background_color => '#00ff00',
60 # TODO: move this to X11::XCB::Window
62 my ($id, $class, $instance) = @_;
64 # Add a _NET_WM_STRUT_PARTIAL hint
65 my $atomname = $x->atom(name => 'WM_CLASS');
66 my $atomtype = $x->atom(name => 'STRING');
74 length($class) + length($instance) + 2,
75 "$instance\x00$class\x00"
79 set_wm_class($window->id, 'borderless', 'borderless');
80 $window->name('Borderless window');
84 @content = @{get_ws_content($tmp)};
85 cmp_ok(@content, '==', 1, 'one node on this workspace now');
86 is($content[0]->{border}, 'none', 'no border');
91 @content = @{get_ws_content($tmp)};
92 cmp_ok(@content, '==', 0, 'no more nodes');
94 exit_gracefully($process->pid);
96 ##############################################################
97 # 2: match on the title, check if for_window is really executed
99 ##############################################################
102 # i3 config file (v4)
103 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
104 for_window [class="borderless"] border none
105 for_window [title="special borderless title"] border none
108 $process = launch_with_config($config);
110 $tmp = fresh_workspace;
112 $window = $x->root->create_child(
113 class => WINDOW_CLASS_INPUT_OUTPUT,
114 rect => [ 0, 0, 30, 30 ],
115 background_color => '#00ff00',
118 $window->name('special title');
122 @content = @{get_ws_content($tmp)};
123 cmp_ok(@content, '==', 1, 'one node on this workspace now');
124 is($content[0]->{border}, 'normal', 'normal border');
126 $window->name('special borderless title');
129 @content = @{get_ws_content($tmp)};
130 is($content[0]->{border}, 'none', 'no border');
132 $window->name('special title');
137 @content = @{get_ws_content($tmp)};
138 is($content[0]->{border}, 'normal', 'border reset to normal');
140 $window->name('special borderless title');
143 @content = @{get_ws_content($tmp)};
144 is($content[0]->{border}, 'normal', 'still normal border');
149 @content = @{get_ws_content($tmp)};
150 cmp_ok(@content, '==', 0, 'no more nodes');
152 exit_gracefully($process->pid);
154 ##############################################################
155 # 3: match on the title, set border style *and* a mark
156 ##############################################################
159 # i3 config file (v4)
160 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
161 for_window [class="borderless" title="usethis"] border none
162 for_window [class="borderless"] border none
163 for_window [title="special borderless title"] border none
164 for_window [title="special mark title"] border none, mark bleh
167 $process = launch_with_config($config);
169 $tmp = fresh_workspace;
171 $window = $x->root->create_child(
172 class => WINDOW_CLASS_INPUT_OUTPUT,
173 rect => [ 0, 0, 30, 30 ],
174 background_color => '#00ff00',
177 $window->name('special mark title');
181 @content = @{get_ws_content($tmp)};
182 cmp_ok(@content, '==', 1, 'one node on this workspace now');
183 is($content[0]->{border}, 'none', 'no border');
185 my $other = open_standard_window($x);
187 @content = @{get_ws_content($tmp)};
188 cmp_ok(@content, '==', 2, 'two nodes');
189 is($content[0]->{border}, 'none', 'no border');
190 is($content[1]->{border}, 'normal', 'normal border');
191 ok(!$content[0]->{focused}, 'first one not focused');
193 cmd qq|[con_mark="bleh"] focus|;
195 @content = @{get_ws_content($tmp)};
196 ok($content[0]->{focused}, 'first node focused');
198 exit_gracefully($process->pid);
200 ##############################################################
201 # 4: multiple criteria for the for_window command
202 ##############################################################
205 # i3 config file (v4)
206 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
207 for_window [class="borderless" title="usethis"] border none
210 $process = launch_with_config($config);
212 $tmp = fresh_workspace;
214 $window = $x->root->create_child(
215 class => WINDOW_CLASS_INPUT_OUTPUT,
216 rect => [ 0, 0, 30, 30 ],
217 background_color => '#00ff00',
222 set_wm_class($window->id, 'borderless', 'borderless');
223 $window->name('usethis');
227 @content = @{get_ws_content($tmp)};
228 cmp_ok(@content, '==', 1, 'one node on this workspace now');
229 is($content[0]->{border}, 'none', 'no border');
234 @content = @{get_ws_content($tmp)};
235 cmp_ok(@content, '==', 0, 'no nodes on this workspace now');
237 set_wm_class($window->id, 'borderless', 'borderless');
238 $window->name('notthis');
242 @content = @{get_ws_content($tmp)};
243 cmp_ok(@content, '==', 1, 'one node on this workspace now');
244 is($content[0]->{border}, 'normal', 'no border');
247 exit_gracefully($process->pid);
249 ##############################################################
250 # 5: check that a class criterion does not match the instance
251 ##############################################################
254 # i3 config file (v4)
255 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
256 for_window [class="foo"] border 1pixel
259 $process = launch_with_config($config);
261 $tmp = fresh_workspace;
263 $window = $x->root->create_child(
264 class => WINDOW_CLASS_INPUT_OUTPUT,
265 rect => [ 0, 0, 30, 30 ],
266 background_color => '#00ff00',
271 set_wm_class($window->id, 'bar', 'foo');
272 $window->name('usethis');
276 @content = @{get_ws_content($tmp)};
277 cmp_ok(@content, '==', 1, 'one node on this workspace now');
278 is($content[0]->{border}, 'normal', 'normal border, not matched');
280 exit_gracefully($process->pid);
282 ##############################################################
283 # 6: check that the 'instance' criterion works
284 ##############################################################
287 # i3 config file (v4)
288 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
289 for_window [class="foo"] border 1pixel
290 for_window [instance="foo"] border none
293 $process = launch_with_config($config);
295 $tmp = fresh_workspace;
297 $window = $x->root->create_child(
298 class => WINDOW_CLASS_INPUT_OUTPUT,
299 rect => [ 0, 0, 30, 30 ],
300 background_color => '#00ff00',
305 set_wm_class($window->id, 'bar', 'foo');
306 $window->name('usethis');
310 @content = @{get_ws_content($tmp)};
311 cmp_ok(@content, '==', 1, 'one node on this workspace now');
312 is($content[0]->{border}, 'none', 'no border');
314 exit_gracefully($process->pid);