2 # vim:ts=4:sw=4:expandtab
4 # Please read the following documents before working on tests:
5 # • https://build.i3wm.org/docs/testsuite.html
8 # • https://build.i3wm.org/docs/lib-i3test.html
9 # (alternatively: perldoc ./testcases/lib/i3test.pm)
11 # • https://build.i3wm.org/docs/ipc.html
14 # • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
15 # (unless you are already familiar with Perl)
17 # Verifies that one can bind on numpad keys in different numlock states.
19 # Bug still in: 4.12-78-g85bb324
20 use i3test i3_autostart => 0;
22 use ExtUtils::PkgConfig;
25 skip "libxcb-xkb too old (need >= 1.11)", 1 unless
26 ExtUtils::PkgConfig->atleast_version('xcb-xkb', '1.11');
30 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
32 # Same key, different numlock states.
33 bindsym Mod2+KP_1 nop KP_1
34 bindsym KP_End nop KP_End
36 # Binding which should work with numlock and without.
39 # Binding which should work with numlock and without, see issue #2418.
40 bindsym Escape nop Escape
42 # Binding which should work with numlock and without, see issue #2418.
43 bindsym Shift+Escape nop Shift+Escape
45 # Binding which should work with numlock and without, see issue #2418.
46 bindsym Mod1+Shift+q nop Mod1+Shift+q
48 # Binding which should work with numlock and without, see issue #2559.
52 my $pid = launch_with_config($config);
54 start_binding_capture;
56 is(listen_for_binding(
58 xtest_key_press(87); # KP_End
59 xtest_key_release(87); # KP_End
64 'triggered the "KP_End" keybinding');
66 is(listen_for_binding(
68 xtest_key_press(77); # enable Num_Lock
69 xtest_key_release(77); # enable Num_Lock
70 xtest_key_press(87); # KP_1
71 xtest_key_release(87); # KP_1
72 xtest_key_press(77); # disable Num_Lock
73 xtest_key_release(77); # disable Num_Lock
78 'triggered the "KP_1" keybinding');
80 is(listen_for_binding(
82 xtest_key_press(133); # Super_L
83 xtest_key_press(38); # a
84 xtest_key_release(38); # a
85 xtest_key_release(133); # Super_L
90 'triggered the "a" keybinding');
92 is(listen_for_binding(
94 xtest_key_press(77); # enable Num_Lock
95 xtest_key_release(77); # enable Num_Lock
96 xtest_key_press(133); # Super_L
97 xtest_key_press(38); # a
98 xtest_key_release(38); # a
99 xtest_key_release(133); # Super_L
100 xtest_key_press(77); # disable Num_Lock
101 xtest_key_release(77); # disable Num_Lock
106 'triggered the "a" keybinding');
108 is(listen_for_binding(
110 xtest_key_press(9); # Escape
111 xtest_key_release(9); # Escape
116 'triggered the "Escape" keybinding');
118 is(listen_for_binding(
120 xtest_key_press(77); # enable Num_Lock
121 xtest_key_release(77); # enable Num_Lock
122 xtest_key_press(9); # Escape
123 xtest_key_release(9); # Escape
124 xtest_key_press(77); # disable Num_Lock
125 xtest_key_release(77); # disable Num_Lock
130 'triggered the "Escape" keybinding');
132 is(listen_for_binding(
134 xtest_key_press(50); # Shift_L
135 xtest_key_press(9); # Escape
136 xtest_key_release(9); # Escape
137 xtest_key_release(50); # Shift_L
142 'triggered the "Escape" keybinding');
144 is(listen_for_binding(
146 xtest_key_press(77); # enable Num_Lock
147 xtest_key_release(77); # enable Num_Lock
148 xtest_key_press(50); # Shift_L
149 xtest_key_press(9); # Escape
150 xtest_key_release(9); # Escape
151 xtest_key_release(50); # Shift_L
152 xtest_key_press(77); # disable Num_Lock
153 xtest_key_release(77); # disable Num_Lock
158 'triggered the "Escape" keybinding');
160 is(listen_for_binding(
162 xtest_key_press(50); # Shift_L
163 xtest_key_press(64); # Alt_L
164 xtest_key_press(24); # q
165 xtest_key_release(24); # q
166 xtest_key_release(64); # Alt_L
167 xtest_key_release(50); # Shift_L
172 'triggered the "Mod1+Shift+q" keybinding');
174 is(listen_for_binding(
176 xtest_key_press(77); # enable Num_Lock
177 xtest_key_release(77); # enable Num_Lock
178 xtest_key_press(50); # Shift_L
179 xtest_key_press(64); # Alt_L
180 xtest_key_press(24); # q
181 xtest_key_release(24); # q
182 xtest_key_release(64); # Alt_L
183 xtest_key_release(50); # Shift_L
184 xtest_key_press(77); # disable Num_Lock
185 xtest_key_release(77); # disable Num_Lock
190 'triggered the "Mod1+Shift+q" keybinding');
192 is(listen_for_binding(
194 xtest_key_press(39); # s
195 xtest_key_release(39); # s
200 'triggered the "s" keybinding without Num_Lock');
202 is(listen_for_binding(
204 xtest_key_press(77); # enable Num_Lock
205 xtest_key_release(77); # enable Num_Lock
206 xtest_key_press(39); # s
207 xtest_key_release(39); # s
208 xtest_key_press(77); # disable Num_Lock
209 xtest_key_release(77); # disable Num_Lock
214 'triggered the "s" keybinding with Num_Lock');
217 is(scalar @i3test::XTEST::binding_events, 12, 'Received exactly 12 binding events');
219 exit_gracefully($pid);
221 ################################################################################
222 # Verify bindings for modifiers work
223 ################################################################################
226 # i3 config file (v4)
227 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
229 bindsym Mod4+Return nop Return
231 # Binding which should work with numlock and without, see issue #2559.
232 bindcode --release 133 nop Super_L
235 $pid = launch_with_config($config);
237 start_binding_capture;
239 is(listen_for_binding(
241 xtest_key_press(133); # Super_L
242 xtest_key_release(133); # Super_L
247 'triggered the "Super_L" keybinding without Num_Lock');
249 is(listen_for_binding(
251 xtest_key_press(77); # enable Num_Lock
252 xtest_key_release(77); # enable Num_Lock
253 xtest_key_press(133); # Super_L
254 xtest_key_release(133); # Super_L
255 xtest_key_press(77); # disable Num_Lock
256 xtest_key_release(77); # disable Num_Lock
261 'triggered the "Super_L" keybinding with Num_Lock');
263 is(listen_for_binding(
265 xtest_key_press(133); # Super_L
266 xtest_key_press(36); # Return
267 xtest_key_release(36); # Return
268 xtest_key_release(133); # Super_L
273 'triggered the "Return" keybinding without Num_Lock');
275 is(listen_for_binding(
277 xtest_key_press(77); # enable Num_Lock
278 xtest_key_release(77); # enable Num_Lock
279 xtest_key_press(133); # Super_L
280 xtest_key_press(36); # Return
281 xtest_key_release(36); # Return
282 xtest_key_release(133); # Super_L
283 xtest_key_press(77); # disable Num_Lock
284 xtest_key_release(77); # disable Num_Lock
289 'triggered the "Return" keybinding with Num_Lock');
292 is(scalar @i3test::XTEST::binding_events, 16, 'Received exactly 16 binding events');
294 exit_gracefully($pid);
296 ################################################################################
297 # Verify the binding is only triggered for KP_End, not KP_1
298 ################################################################################
301 # i3 config file (v4)
302 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
304 bindsym KP_End nop KP_End
305 bindcode 88 nop KP_Down
308 $pid = launch_with_config($config);
310 start_binding_capture;
312 is(listen_for_binding(
314 xtest_key_press(87); # KP_End
315 xtest_key_release(87); # KP_End
320 'triggered the "KP_End" keybinding');
322 is(listen_for_binding(
324 xtest_key_press(88); # KP_Down
325 xtest_key_release(88); # KP_Down
330 'triggered the "KP_Down" keybinding');
332 is(listen_for_binding(
334 xtest_key_press(77); # enable Num_Lock
335 xtest_key_release(77); # enable Num_Lock
336 xtest_key_press(87); # KP_1
337 xtest_key_release(87); # KP_1
338 xtest_key_press(77); # disable Num_Lock
339 xtest_key_release(77); # disable Num_Lock
344 'Did not trigger the KP_End keybinding with KP_1');
346 is(listen_for_binding(
348 xtest_key_press(77); # enable Num_Lock
349 xtest_key_release(77); # enable Num_Lock
350 xtest_key_press(88); # KP_2
351 xtest_key_release(88); # KP_2
352 xtest_key_press(77); # disable Num_Lock
353 xtest_key_release(77); # disable Num_Lock
358 'Did not trigger the KP_Down keybinding with KP_2');
360 # TODO: This test does not verify that i3 does _NOT_ grab keycode 87 with Mod2.
363 is(scalar @i3test::XTEST::binding_events, 18, 'Received exactly 18 binding events');
365 exit_gracefully($pid);
367 ################################################################################
368 # Verify mouse bindings are unaffected by NumLock
369 ################################################################################
372 # i3 config file (v4)
373 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
375 bindsym --whole-window button4 nop button4
378 $pid = launch_with_config($config);
380 my $win = open_window;
382 start_binding_capture;
384 is(listen_for_binding(
386 xtest_key_press(77); # enable Num_Lock
387 xtest_key_release(77); # enable Num_Lock
388 xtest_button_press(4, 50, 50);
389 xtest_button_release(4, 50, 50);
390 xtest_key_press(77); # disable Num_Lock
391 xtest_key_release(77); # disable Num_Lock
396 'triggered the button4 keybinding with NumLock');
398 is(listen_for_binding(
400 xtest_button_press(4, 50, 50);
401 xtest_button_release(4, 50, 50);
406 'triggered the button4 keybinding without NumLock');
408 exit_gracefully($pid);