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 is(listen_for_binding(
56 xtest_key_press(87); # KP_End
57 xtest_key_release(87); # KP_End
62 'triggered the "KP_End" keybinding');
64 is(listen_for_binding(
66 xtest_key_press(77); # enable Num_Lock
67 xtest_key_release(77); # enable Num_Lock
68 xtest_key_press(87); # KP_1
69 xtest_key_release(87); # KP_1
70 xtest_key_press(77); # disable Num_Lock
71 xtest_key_release(77); # disable Num_Lock
76 'triggered the "KP_1" keybinding');
78 is(listen_for_binding(
80 xtest_key_press(133); # Super_L
81 xtest_key_press(38); # a
82 xtest_key_release(38); # a
83 xtest_key_release(133); # Super_L
88 'triggered the "a" keybinding');
90 is(listen_for_binding(
92 xtest_key_press(77); # enable Num_Lock
93 xtest_key_release(77); # enable Num_Lock
94 xtest_key_press(133); # Super_L
95 xtest_key_press(38); # a
96 xtest_key_release(38); # a
97 xtest_key_release(133); # Super_L
98 xtest_key_press(77); # disable Num_Lock
99 xtest_key_release(77); # disable Num_Lock
104 'triggered the "a" keybinding');
106 is(listen_for_binding(
108 xtest_key_press(9); # Escape
109 xtest_key_release(9); # Escape
114 'triggered the "Escape" keybinding');
116 is(listen_for_binding(
118 xtest_key_press(77); # enable Num_Lock
119 xtest_key_release(77); # enable Num_Lock
120 xtest_key_press(9); # Escape
121 xtest_key_release(9); # Escape
122 xtest_key_press(77); # disable Num_Lock
123 xtest_key_release(77); # disable Num_Lock
128 'triggered the "Escape" keybinding');
130 is(listen_for_binding(
132 xtest_key_press(50); # Shift_L
133 xtest_key_press(9); # Escape
134 xtest_key_release(9); # Escape
135 xtest_key_release(50); # Shift_L
140 'triggered the "Escape" keybinding');
142 is(listen_for_binding(
144 xtest_key_press(77); # enable Num_Lock
145 xtest_key_release(77); # enable Num_Lock
146 xtest_key_press(50); # Shift_L
147 xtest_key_press(9); # Escape
148 xtest_key_release(9); # Escape
149 xtest_key_release(50); # Shift_L
150 xtest_key_press(77); # disable Num_Lock
151 xtest_key_release(77); # disable Num_Lock
156 'triggered the "Escape" keybinding');
158 is(listen_for_binding(
160 xtest_key_press(50); # Shift_L
161 xtest_key_press(64); # Alt_L
162 xtest_key_press(24); # q
163 xtest_key_release(24); # q
164 xtest_key_release(64); # Alt_L
165 xtest_key_release(50); # Shift_L
170 'triggered the "Mod1+Shift+q" keybinding');
172 is(listen_for_binding(
174 xtest_key_press(77); # enable Num_Lock
175 xtest_key_release(77); # enable Num_Lock
176 xtest_key_press(50); # Shift_L
177 xtest_key_press(64); # Alt_L
178 xtest_key_press(24); # q
179 xtest_key_release(24); # q
180 xtest_key_release(64); # Alt_L
181 xtest_key_release(50); # Shift_L
182 xtest_key_press(77); # disable Num_Lock
183 xtest_key_release(77); # disable Num_Lock
188 'triggered the "Mod1+Shift+q" keybinding');
190 is(listen_for_binding(
192 xtest_key_press(39); # s
193 xtest_key_release(39); # s
198 'triggered the "s" keybinding without Num_Lock');
200 is(listen_for_binding(
202 xtest_key_press(77); # enable Num_Lock
203 xtest_key_release(77); # enable Num_Lock
204 xtest_key_press(39); # s
205 xtest_key_release(39); # s
206 xtest_key_press(77); # disable Num_Lock
207 xtest_key_release(77); # disable Num_Lock
212 'triggered the "s" keybinding with Num_Lock');
214 exit_gracefully($pid);
216 ################################################################################
217 # Verify bindings for modifiers work
218 ################################################################################
221 # i3 config file (v4)
222 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
224 bindsym Mod4+Return nop Return
226 # Binding which should work with numlock and without, see issue #2559.
227 bindcode --release 133 nop Super_L
230 $pid = launch_with_config($config);
232 is(listen_for_binding(
234 xtest_key_press(133); # Super_L
235 xtest_key_release(133); # Super_L
240 'triggered the "Super_L" keybinding without Num_Lock');
242 is(listen_for_binding(
244 xtest_key_press(77); # enable Num_Lock
245 xtest_key_release(77); # enable Num_Lock
246 xtest_key_press(133); # Super_L
247 xtest_key_release(133); # Super_L
248 xtest_key_press(77); # disable Num_Lock
249 xtest_key_release(77); # disable Num_Lock
254 'triggered the "Super_L" keybinding with Num_Lock');
256 is(listen_for_binding(
258 xtest_key_press(133); # Super_L
259 xtest_key_press(36); # Return
260 xtest_key_release(36); # Return
261 xtest_key_release(133); # Super_L
266 'triggered the "Return" keybinding without Num_Lock');
268 is(listen_for_binding(
270 xtest_key_press(77); # enable Num_Lock
271 xtest_key_release(77); # enable Num_Lock
272 xtest_key_press(133); # Super_L
273 xtest_key_press(36); # Return
274 xtest_key_release(36); # Return
275 xtest_key_release(133); # Super_L
276 xtest_key_press(77); # disable Num_Lock
277 xtest_key_release(77); # disable Num_Lock
282 'triggered the "Return" keybinding with Num_Lock');
284 exit_gracefully($pid);
286 ################################################################################
287 # Verify the binding is only triggered for KP_End, not KP_1
288 ################################################################################
291 # i3 config file (v4)
292 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
294 bindsym KP_End nop KP_End
295 bindcode 88 nop KP_Down
298 $pid = launch_with_config($config);
300 is(listen_for_binding(
302 xtest_key_press(87); # KP_End
303 xtest_key_release(87); # KP_End
308 'triggered the "KP_End" keybinding');
310 is(listen_for_binding(
312 xtest_key_press(88); # KP_Down
313 xtest_key_release(88); # KP_Down
318 'triggered the "KP_Down" keybinding');
320 my @unexpected = events_for(
322 xtest_key_press(77); # enable Num_Lock
323 xtest_key_release(77); # enable Num_Lock
324 xtest_key_press(87); # KP_1
325 xtest_key_release(87); # KP_1
326 xtest_key_press(77); # disable Num_Lock
327 xtest_key_release(77); # disable Num_Lock
331 is(scalar @unexpected, 0, 'Did not trigger the KP_End keybinding with KP_1');
333 my @unexpected2 = events_for(
335 xtest_key_press(77); # enable Num_Lock
336 xtest_key_release(77); # enable Num_Lock
337 xtest_key_press(88); # KP_2
338 xtest_key_release(88); # KP_2
339 xtest_key_press(77); # disable Num_Lock
340 xtest_key_release(77); # disable Num_Lock
345 is(scalar @unexpected2, 0, 'Did not trigger the KP_Down keybinding with KP_2');
347 # TODO: This test does not verify that i3 does _NOT_ grab keycode 87 with Mod2.
349 exit_gracefully($pid);
351 ################################################################################
352 # Verify mouse bindings are unaffected by NumLock
353 ################################################################################
356 # i3 config file (v4)
357 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
359 bindsym --whole-window button4 nop button4
362 $pid = launch_with_config($config);
364 my $win = open_window;
366 is(listen_for_binding(
368 xtest_key_press(77); # enable Num_Lock
369 xtest_key_release(77); # enable Num_Lock
370 xtest_button_press(4, 50, 50);
371 xtest_button_release(4, 50, 50);
372 xtest_key_press(77); # disable Num_Lock
373 xtest_key_release(77); # disable Num_Lock
378 'triggered the button4 keybinding with NumLock');
380 is(listen_for_binding(
382 xtest_button_press(4, 50, 50);
383 xtest_button_release(4, 50, 50);
388 'triggered the button4 keybinding without NumLock');
390 exit_gracefully($pid);