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
63 'triggered the "KP_End" keybinding');
65 is(listen_for_binding(
67 xtest_key_press(77); # enable Num_Lock
68 xtest_key_release(77); # enable Num_Lock
69 xtest_key_press(87); # KP_1
70 xtest_key_release(87); # KP_1
71 xtest_key_press(77); # disable Num_Lock
72 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
87 'triggered the "a" keybinding');
89 is(listen_for_binding(
91 xtest_key_press(77); # enable Num_Lock
92 xtest_key_release(77); # enable Num_Lock
93 xtest_key_press(133); # Super_L
94 xtest_key_press(38); # a
95 xtest_key_release(38); # a
96 xtest_key_release(133); # Super_L
97 xtest_key_press(77); # disable Num_Lock
98 xtest_key_release(77); # disable Num_Lock
102 'triggered the "a" keybinding');
104 is(listen_for_binding(
106 xtest_key_press(9); # Escape
107 xtest_key_release(9); # Escape
111 'triggered the "Escape" keybinding');
113 is(listen_for_binding(
115 xtest_key_press(77); # enable Num_Lock
116 xtest_key_release(77); # enable Num_Lock
117 xtest_key_press(9); # Escape
118 xtest_key_release(9); # Escape
119 xtest_key_press(77); # disable Num_Lock
120 xtest_key_release(77); # disable Num_Lock
124 'triggered the "Escape" keybinding');
126 is(listen_for_binding(
128 xtest_key_press(50); # Shift_L
129 xtest_key_press(9); # Escape
130 xtest_key_release(9); # Escape
131 xtest_key_release(50); # Shift_L
135 'triggered the "Escape" keybinding');
137 is(listen_for_binding(
139 xtest_key_press(77); # enable Num_Lock
140 xtest_key_release(77); # enable Num_Lock
141 xtest_key_press(50); # Shift_L
142 xtest_key_press(9); # Escape
143 xtest_key_release(9); # Escape
144 xtest_key_release(50); # Shift_L
145 xtest_key_press(77); # disable Num_Lock
146 xtest_key_release(77); # disable Num_Lock
150 'triggered the "Escape" keybinding');
152 is(listen_for_binding(
154 xtest_key_press(50); # Shift_L
155 xtest_key_press(64); # Alt_L
156 xtest_key_press(24); # q
157 xtest_key_release(24); # q
158 xtest_key_release(64); # Alt_L
159 xtest_key_release(50); # Shift_L
163 'triggered the "Mod1+Shift+q" keybinding');
165 is(listen_for_binding(
167 xtest_key_press(77); # enable Num_Lock
168 xtest_key_release(77); # enable Num_Lock
169 xtest_key_press(50); # Shift_L
170 xtest_key_press(64); # Alt_L
171 xtest_key_press(24); # q
172 xtest_key_release(24); # q
173 xtest_key_release(64); # Alt_L
174 xtest_key_release(50); # Shift_L
175 xtest_key_press(77); # disable Num_Lock
176 xtest_key_release(77); # disable Num_Lock
180 'triggered the "Mod1+Shift+q" keybinding');
182 is(listen_for_binding(
184 xtest_key_press(39); # s
185 xtest_key_release(39); # s
189 'triggered the "s" keybinding without Num_Lock');
191 is(listen_for_binding(
193 xtest_key_press(77); # enable Num_Lock
194 xtest_key_release(77); # enable Num_Lock
195 xtest_key_press(39); # s
196 xtest_key_release(39); # s
197 xtest_key_press(77); # disable Num_Lock
198 xtest_key_release(77); # disable Num_Lock
202 'triggered the "s" keybinding with Num_Lock');
205 is(scalar @i3test::XTEST::binding_events, 12, 'Received exactly 12 binding events');
207 exit_gracefully($pid);
209 ################################################################################
210 # Verify bindings for modifiers work
211 ################################################################################
214 # i3 config file (v4)
215 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
217 bindsym Mod4+Return nop Return
219 # Binding which should work with numlock and without, see issue #2559.
220 bindcode --release 133 nop Super_L
223 $pid = launch_with_config($config);
225 start_binding_capture;
227 is(listen_for_binding(
229 xtest_key_press(133); # Super_L
230 xtest_key_release(133); # Super_L
234 'triggered the "Super_L" keybinding without Num_Lock');
236 is(listen_for_binding(
238 xtest_key_press(77); # enable Num_Lock
239 xtest_key_release(77); # enable Num_Lock
240 xtest_key_press(133); # Super_L
241 xtest_key_release(133); # Super_L
242 xtest_key_press(77); # disable Num_Lock
243 xtest_key_release(77); # disable Num_Lock
247 'triggered the "Super_L" keybinding with Num_Lock');
249 is(listen_for_binding(
251 xtest_key_press(133); # Super_L
252 xtest_key_press(36); # Return
253 xtest_key_release(36); # Return
254 xtest_key_release(133); # Super_L
258 'triggered the "Return" keybinding without Num_Lock');
260 is(listen_for_binding(
262 xtest_key_press(77); # enable Num_Lock
263 xtest_key_release(77); # enable Num_Lock
264 xtest_key_press(133); # Super_L
265 xtest_key_press(36); # Return
266 xtest_key_release(36); # Return
267 xtest_key_release(133); # Super_L
268 xtest_key_press(77); # disable Num_Lock
269 xtest_key_release(77); # disable Num_Lock
273 'triggered the "Return" keybinding with Num_Lock');
276 is(scalar @i3test::XTEST::binding_events, 16, 'Received exactly 16 binding events');
278 exit_gracefully($pid);
280 ################################################################################
281 # Verify the binding is only triggered for KP_End, not KP_1
282 ################################################################################
285 # i3 config file (v4)
286 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
288 bindsym KP_End nop KP_End
289 bindcode 88 nop KP_Down
292 $pid = launch_with_config($config);
294 start_binding_capture;
296 is(listen_for_binding(
298 xtest_key_press(87); # KP_End
299 xtest_key_release(87); # KP_End
303 'triggered the "KP_End" keybinding');
305 is(listen_for_binding(
307 xtest_key_press(88); # KP_Down
308 xtest_key_release(88); # KP_Down
312 'triggered the "KP_Down" keybinding');
314 is(listen_for_binding(
316 xtest_key_press(77); # enable Num_Lock
317 xtest_key_release(77); # enable Num_Lock
318 xtest_key_press(87); # KP_1
319 xtest_key_release(87); # KP_1
320 xtest_key_press(77); # disable Num_Lock
321 xtest_key_release(77); # disable Num_Lock
325 'Did not trigger the KP_End keybinding with KP_1');
327 is(listen_for_binding(
329 xtest_key_press(77); # enable Num_Lock
330 xtest_key_release(77); # enable Num_Lock
331 xtest_key_press(88); # KP_2
332 xtest_key_release(88); # KP_2
333 xtest_key_press(77); # disable Num_Lock
334 xtest_key_release(77); # disable Num_Lock
338 'Did not trigger the KP_Down keybinding with KP_2');
340 # TODO: This test does not verify that i3 does _NOT_ grab keycode 87 with Mod2.
343 is(scalar @i3test::XTEST::binding_events, 18, 'Received exactly 18 binding events');
345 exit_gracefully($pid);
347 ################################################################################
348 # Verify mouse bindings are unaffected by NumLock
349 ################################################################################
352 # i3 config file (v4)
353 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
355 bindsym --whole-window button4 nop button4
358 $pid = launch_with_config($config);
360 my $win = open_window;
362 start_binding_capture;
364 is(listen_for_binding(
366 xtest_key_press(77); # enable Num_Lock
367 xtest_key_release(77); # enable Num_Lock
368 xtest_button_press(4, 50, 50);
369 xtest_button_release(4, 50, 50);
370 xtest_key_press(77); # disable Num_Lock
371 xtest_key_release(77); # disable Num_Lock
375 'triggered the button4 keybinding with NumLock');
377 is(listen_for_binding(
379 xtest_button_press(4, 50, 50);
380 xtest_button_release(4, 50, 50);
384 'triggered the button4 keybinding without NumLock');
386 exit_gracefully($pid);