2016-08-02 20:23:53 +02:00
|
|
|
#!perl
|
|
|
|
# vim:ts=4:sw=4:expandtab
|
|
|
|
#
|
|
|
|
# Please read the following documents before working on tests:
|
2017-09-24 10:19:50 +02:00
|
|
|
# • https://build.i3wm.org/docs/testsuite.html
|
2016-08-02 20:23:53 +02:00
|
|
|
# (or docs/testsuite)
|
|
|
|
#
|
2017-09-24 10:19:50 +02:00
|
|
|
# • https://build.i3wm.org/docs/lib-i3test.html
|
2016-08-02 20:23:53 +02:00
|
|
|
# (alternatively: perldoc ./testcases/lib/i3test.pm)
|
|
|
|
#
|
2017-09-24 10:19:50 +02:00
|
|
|
# • https://build.i3wm.org/docs/ipc.html
|
2016-08-02 20:23:53 +02:00
|
|
|
# (or docs/ipc)
|
|
|
|
#
|
|
|
|
# • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
|
|
|
|
# (unless you are already familiar with Perl)
|
|
|
|
#
|
|
|
|
# Verifies that one can bind on numpad keys in different numlock states.
|
|
|
|
# Ticket: #2346
|
|
|
|
# Bug still in: 4.12-78-g85bb324
|
|
|
|
use i3test i3_autostart => 0;
|
|
|
|
use i3test::XTEST;
|
|
|
|
use ExtUtils::PkgConfig;
|
|
|
|
|
|
|
|
SKIP: {
|
|
|
|
skip "libxcb-xkb too old (need >= 1.11)", 1 unless
|
|
|
|
ExtUtils::PkgConfig->atleast_version('xcb-xkb', '1.11');
|
|
|
|
|
|
|
|
my $config = <<EOT;
|
|
|
|
# i3 config file (v4)
|
|
|
|
font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
|
|
|
|
|
|
|
|
# Same key, different numlock states.
|
|
|
|
bindsym Mod2+KP_1 nop KP_1
|
|
|
|
bindsym KP_End nop KP_End
|
|
|
|
|
|
|
|
# Binding which should work with numlock and without.
|
|
|
|
bindsym Mod4+a nop a
|
2016-09-12 12:05:38 +02:00
|
|
|
|
|
|
|
# Binding which should work with numlock and without, see issue #2418.
|
|
|
|
bindsym Escape nop Escape
|
2016-09-12 12:10:59 +02:00
|
|
|
|
|
|
|
# Binding which should work with numlock and without, see issue #2418.
|
|
|
|
bindsym Shift+Escape nop Shift+Escape
|
2016-09-12 22:24:23 +02:00
|
|
|
|
|
|
|
# Binding which should work with numlock and without, see issue #2418.
|
|
|
|
bindsym Mod1+Shift+q nop Mod1+Shift+q
|
2017-05-22 21:32:05 +02:00
|
|
|
|
|
|
|
# Binding which should work with numlock and without, see issue #2559.
|
|
|
|
bindcode 39 nop s
|
2016-08-02 20:23:53 +02:00
|
|
|
EOT
|
|
|
|
|
|
|
|
my $pid = launch_with_config($config);
|
|
|
|
|
|
|
|
start_binding_capture;
|
|
|
|
|
|
|
|
is(listen_for_binding(
|
|
|
|
sub {
|
|
|
|
xtest_key_press(87); # KP_End
|
|
|
|
xtest_key_release(87); # KP_End
|
|
|
|
},
|
|
|
|
),
|
|
|
|
'KP_End',
|
|
|
|
'triggered the "KP_End" keybinding');
|
|
|
|
|
|
|
|
is(listen_for_binding(
|
|
|
|
sub {
|
2016-09-12 12:05:38 +02:00
|
|
|
xtest_key_press(77); # enable Num_Lock
|
|
|
|
xtest_key_release(77); # enable Num_Lock
|
2016-08-02 20:23:53 +02:00
|
|
|
xtest_key_press(87); # KP_1
|
|
|
|
xtest_key_release(87); # KP_1
|
2016-09-12 12:05:38 +02:00
|
|
|
xtest_key_press(77); # disable Num_Lock
|
|
|
|
xtest_key_release(77); # disable Num_Lock
|
2016-08-02 20:23:53 +02:00
|
|
|
},
|
|
|
|
),
|
|
|
|
'KP_1',
|
|
|
|
'triggered the "KP_1" keybinding');
|
|
|
|
|
|
|
|
is(listen_for_binding(
|
|
|
|
sub {
|
|
|
|
xtest_key_press(133); # Super_L
|
|
|
|
xtest_key_press(38); # a
|
|
|
|
xtest_key_release(38); # a
|
|
|
|
xtest_key_release(133); # Super_L
|
|
|
|
},
|
|
|
|
),
|
|
|
|
'a',
|
|
|
|
'triggered the "a" keybinding');
|
|
|
|
|
|
|
|
is(listen_for_binding(
|
|
|
|
sub {
|
2016-09-12 12:05:38 +02:00
|
|
|
xtest_key_press(77); # enable Num_Lock
|
|
|
|
xtest_key_release(77); # enable Num_Lock
|
2016-08-02 20:23:53 +02:00
|
|
|
xtest_key_press(133); # Super_L
|
|
|
|
xtest_key_press(38); # a
|
|
|
|
xtest_key_release(38); # a
|
|
|
|
xtest_key_release(133); # Super_L
|
2016-09-12 12:05:38 +02:00
|
|
|
xtest_key_press(77); # disable Num_Lock
|
|
|
|
xtest_key_release(77); # disable Num_Lock
|
2016-08-02 20:23:53 +02:00
|
|
|
},
|
|
|
|
),
|
|
|
|
'a',
|
|
|
|
'triggered the "a" keybinding');
|
|
|
|
|
2016-09-12 12:05:38 +02:00
|
|
|
is(listen_for_binding(
|
|
|
|
sub {
|
|
|
|
xtest_key_press(9); # Escape
|
|
|
|
xtest_key_release(9); # Escape
|
|
|
|
},
|
|
|
|
),
|
|
|
|
'Escape',
|
|
|
|
'triggered the "Escape" keybinding');
|
|
|
|
|
|
|
|
is(listen_for_binding(
|
|
|
|
sub {
|
|
|
|
xtest_key_press(77); # enable Num_Lock
|
|
|
|
xtest_key_release(77); # enable Num_Lock
|
|
|
|
xtest_key_press(9); # Escape
|
|
|
|
xtest_key_release(9); # Escape
|
|
|
|
xtest_key_press(77); # disable Num_Lock
|
|
|
|
xtest_key_release(77); # disable Num_Lock
|
|
|
|
},
|
|
|
|
),
|
|
|
|
'Escape',
|
|
|
|
'triggered the "Escape" keybinding');
|
2016-08-02 20:23:53 +02:00
|
|
|
|
2016-09-12 12:10:59 +02:00
|
|
|
is(listen_for_binding(
|
|
|
|
sub {
|
|
|
|
xtest_key_press(50); # Shift_L
|
|
|
|
xtest_key_press(9); # Escape
|
|
|
|
xtest_key_release(9); # Escape
|
|
|
|
xtest_key_release(50); # Shift_L
|
|
|
|
},
|
|
|
|
),
|
|
|
|
'Shift+Escape',
|
|
|
|
'triggered the "Escape" keybinding');
|
|
|
|
|
|
|
|
is(listen_for_binding(
|
|
|
|
sub {
|
|
|
|
xtest_key_press(77); # enable Num_Lock
|
|
|
|
xtest_key_release(77); # enable Num_Lock
|
|
|
|
xtest_key_press(50); # Shift_L
|
|
|
|
xtest_key_press(9); # Escape
|
|
|
|
xtest_key_release(9); # Escape
|
|
|
|
xtest_key_release(50); # Shift_L
|
|
|
|
xtest_key_press(77); # disable Num_Lock
|
|
|
|
xtest_key_release(77); # disable Num_Lock
|
|
|
|
},
|
|
|
|
),
|
|
|
|
'Shift+Escape',
|
|
|
|
'triggered the "Escape" keybinding');
|
|
|
|
|
2016-09-12 22:24:23 +02:00
|
|
|
is(listen_for_binding(
|
|
|
|
sub {
|
|
|
|
xtest_key_press(50); # Shift_L
|
|
|
|
xtest_key_press(64); # Alt_L
|
|
|
|
xtest_key_press(24); # q
|
|
|
|
xtest_key_release(24); # q
|
|
|
|
xtest_key_release(64); # Alt_L
|
|
|
|
xtest_key_release(50); # Shift_L
|
|
|
|
},
|
|
|
|
),
|
|
|
|
'Mod1+Shift+q',
|
|
|
|
'triggered the "Mod1+Shift+q" keybinding');
|
|
|
|
|
|
|
|
is(listen_for_binding(
|
|
|
|
sub {
|
|
|
|
xtest_key_press(77); # enable Num_Lock
|
|
|
|
xtest_key_release(77); # enable Num_Lock
|
|
|
|
xtest_key_press(50); # Shift_L
|
|
|
|
xtest_key_press(64); # Alt_L
|
|
|
|
xtest_key_press(24); # q
|
|
|
|
xtest_key_release(24); # q
|
|
|
|
xtest_key_release(64); # Alt_L
|
|
|
|
xtest_key_release(50); # Shift_L
|
|
|
|
xtest_key_press(77); # disable Num_Lock
|
|
|
|
xtest_key_release(77); # disable Num_Lock
|
|
|
|
},
|
|
|
|
),
|
|
|
|
'Mod1+Shift+q',
|
|
|
|
'triggered the "Mod1+Shift+q" keybinding');
|
|
|
|
|
2017-05-22 21:32:05 +02:00
|
|
|
is(listen_for_binding(
|
|
|
|
sub {
|
|
|
|
xtest_key_press(39); # s
|
|
|
|
xtest_key_release(39); # s
|
|
|
|
},
|
|
|
|
),
|
|
|
|
's',
|
|
|
|
'triggered the "s" keybinding without Num_Lock');
|
|
|
|
|
|
|
|
is(listen_for_binding(
|
|
|
|
sub {
|
|
|
|
xtest_key_press(77); # enable Num_Lock
|
|
|
|
xtest_key_release(77); # enable Num_Lock
|
|
|
|
xtest_key_press(39); # s
|
|
|
|
xtest_key_release(39); # s
|
|
|
|
xtest_key_press(77); # disable Num_Lock
|
|
|
|
xtest_key_release(77); # disable Num_Lock
|
|
|
|
},
|
|
|
|
),
|
|
|
|
's',
|
|
|
|
'triggered the "s" keybinding with Num_Lock');
|
|
|
|
|
2016-08-02 20:23:53 +02:00
|
|
|
sync_with_i3;
|
2017-05-22 21:32:05 +02:00
|
|
|
is(scalar @i3test::XTEST::binding_events, 12, 'Received exactly 12 binding events');
|
2016-08-02 20:23:53 +02:00
|
|
|
|
|
|
|
exit_gracefully($pid);
|
|
|
|
|
2017-05-23 08:28:56 +02:00
|
|
|
################################################################################
|
|
|
|
# Verify bindings for modifiers work
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
$config = <<EOT;
|
|
|
|
# i3 config file (v4)
|
|
|
|
font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
|
|
|
|
|
2017-05-24 20:42:27 +02:00
|
|
|
bindsym Mod4+Return nop Return
|
|
|
|
|
2017-05-23 08:28:56 +02:00
|
|
|
# Binding which should work with numlock and without, see issue #2559.
|
|
|
|
bindcode --release 133 nop Super_L
|
|
|
|
EOT
|
|
|
|
|
|
|
|
$pid = launch_with_config($config);
|
|
|
|
|
|
|
|
start_binding_capture;
|
|
|
|
|
|
|
|
is(listen_for_binding(
|
|
|
|
sub {
|
|
|
|
xtest_key_press(133); # Super_L
|
|
|
|
xtest_key_release(133); # Super_L
|
|
|
|
},
|
|
|
|
),
|
|
|
|
'Super_L',
|
|
|
|
'triggered the "Super_L" keybinding without Num_Lock');
|
|
|
|
|
|
|
|
is(listen_for_binding(
|
|
|
|
sub {
|
|
|
|
xtest_key_press(77); # enable Num_Lock
|
|
|
|
xtest_key_release(77); # enable Num_Lock
|
|
|
|
xtest_key_press(133); # Super_L
|
|
|
|
xtest_key_release(133); # Super_L
|
|
|
|
xtest_key_press(77); # disable Num_Lock
|
|
|
|
xtest_key_release(77); # disable Num_Lock
|
|
|
|
},
|
|
|
|
),
|
|
|
|
'Super_L',
|
|
|
|
'triggered the "Super_L" keybinding with Num_Lock');
|
|
|
|
|
2017-05-24 20:42:27 +02:00
|
|
|
is(listen_for_binding(
|
|
|
|
sub {
|
|
|
|
xtest_key_press(133); # Super_L
|
|
|
|
xtest_key_press(36); # Return
|
|
|
|
xtest_key_release(36); # Return
|
|
|
|
xtest_key_release(133); # Super_L
|
|
|
|
},
|
|
|
|
),
|
|
|
|
'Return',
|
|
|
|
'triggered the "Return" keybinding without Num_Lock');
|
|
|
|
|
|
|
|
is(listen_for_binding(
|
|
|
|
sub {
|
|
|
|
xtest_key_press(77); # enable Num_Lock
|
|
|
|
xtest_key_release(77); # enable Num_Lock
|
|
|
|
xtest_key_press(133); # Super_L
|
|
|
|
xtest_key_press(36); # Return
|
|
|
|
xtest_key_release(36); # Return
|
|
|
|
xtest_key_release(133); # Super_L
|
|
|
|
xtest_key_press(77); # disable Num_Lock
|
|
|
|
xtest_key_release(77); # disable Num_Lock
|
|
|
|
},
|
|
|
|
),
|
|
|
|
'Return',
|
|
|
|
'triggered the "Return" keybinding with Num_Lock');
|
|
|
|
|
2017-05-23 08:28:56 +02:00
|
|
|
sync_with_i3;
|
2017-05-24 20:42:27 +02:00
|
|
|
is(scalar @i3test::XTEST::binding_events, 16, 'Received exactly 16 binding events');
|
2017-05-23 08:28:56 +02:00
|
|
|
|
|
|
|
exit_gracefully($pid);
|
|
|
|
|
2016-08-02 20:23:53 +02:00
|
|
|
################################################################################
|
|
|
|
# Verify the binding is only triggered for KP_End, not KP_1
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
$config = <<EOT;
|
|
|
|
# i3 config file (v4)
|
|
|
|
font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
|
|
|
|
|
|
|
|
bindsym KP_End nop KP_End
|
2017-05-22 21:32:05 +02:00
|
|
|
bindcode 88 nop KP_Down
|
2016-08-02 20:23:53 +02:00
|
|
|
EOT
|
|
|
|
|
|
|
|
$pid = launch_with_config($config);
|
|
|
|
|
|
|
|
start_binding_capture;
|
|
|
|
|
|
|
|
is(listen_for_binding(
|
|
|
|
sub {
|
|
|
|
xtest_key_press(87); # KP_End
|
|
|
|
xtest_key_release(87); # KP_End
|
|
|
|
},
|
|
|
|
),
|
|
|
|
'KP_End',
|
|
|
|
'triggered the "KP_End" keybinding');
|
|
|
|
|
2017-05-22 21:32:05 +02:00
|
|
|
is(listen_for_binding(
|
|
|
|
sub {
|
|
|
|
xtest_key_press(88); # KP_Down
|
|
|
|
xtest_key_release(88); # KP_Down
|
|
|
|
},
|
|
|
|
),
|
|
|
|
'KP_Down',
|
|
|
|
'triggered the "KP_Down" keybinding');
|
|
|
|
|
2016-08-02 20:23:53 +02:00
|
|
|
is(listen_for_binding(
|
|
|
|
sub {
|
2016-09-12 12:05:38 +02:00
|
|
|
xtest_key_press(77); # enable Num_Lock
|
|
|
|
xtest_key_release(77); # enable Num_Lock
|
2016-08-02 20:23:53 +02:00
|
|
|
xtest_key_press(87); # KP_1
|
|
|
|
xtest_key_release(87); # KP_1
|
2016-09-12 12:05:38 +02:00
|
|
|
xtest_key_press(77); # disable Num_Lock
|
|
|
|
xtest_key_release(77); # disable Num_Lock
|
2016-08-02 20:23:53 +02:00
|
|
|
},
|
|
|
|
),
|
|
|
|
'timeout',
|
|
|
|
'Did not trigger the KP_End keybinding with KP_1');
|
|
|
|
|
2017-05-22 21:32:05 +02:00
|
|
|
is(listen_for_binding(
|
|
|
|
sub {
|
|
|
|
xtest_key_press(77); # enable Num_Lock
|
|
|
|
xtest_key_release(77); # enable Num_Lock
|
|
|
|
xtest_key_press(88); # KP_2
|
|
|
|
xtest_key_release(88); # KP_2
|
|
|
|
xtest_key_press(77); # disable Num_Lock
|
|
|
|
xtest_key_release(77); # disable Num_Lock
|
|
|
|
},
|
|
|
|
),
|
|
|
|
'timeout',
|
|
|
|
'Did not trigger the KP_Down keybinding with KP_2');
|
|
|
|
|
2016-08-02 20:23:53 +02:00
|
|
|
# TODO: This test does not verify that i3 does _NOT_ grab keycode 87 with Mod2.
|
|
|
|
|
|
|
|
sync_with_i3;
|
2017-05-24 20:42:27 +02:00
|
|
|
is(scalar @i3test::XTEST::binding_events, 18, 'Received exactly 18 binding events');
|
2016-08-02 20:23:53 +02:00
|
|
|
|
|
|
|
exit_gracefully($pid);
|
|
|
|
|
2017-08-20 18:00:10 +02:00
|
|
|
################################################################################
|
|
|
|
# Verify mouse bindings are unaffected by NumLock
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
$config = <<EOT;
|
|
|
|
# i3 config file (v4)
|
|
|
|
font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
|
|
|
|
|
|
|
|
bindsym --whole-window button4 nop button4
|
|
|
|
EOT
|
|
|
|
|
|
|
|
$pid = launch_with_config($config);
|
|
|
|
|
|
|
|
my $win = open_window;
|
|
|
|
|
|
|
|
start_binding_capture;
|
|
|
|
|
|
|
|
is(listen_for_binding(
|
|
|
|
sub {
|
|
|
|
xtest_key_press(77); # enable Num_Lock
|
|
|
|
xtest_key_release(77); # enable Num_Lock
|
|
|
|
xtest_button_press(4, 50, 50);
|
|
|
|
xtest_button_release(4, 50, 50);
|
|
|
|
xtest_key_press(77); # disable Num_Lock
|
|
|
|
xtest_key_release(77); # disable Num_Lock
|
|
|
|
},
|
|
|
|
),
|
|
|
|
'button4',
|
|
|
|
'triggered the button4 keybinding with NumLock');
|
|
|
|
|
|
|
|
is(listen_for_binding(
|
|
|
|
sub {
|
|
|
|
xtest_button_press(4, 50, 50);
|
|
|
|
xtest_button_release(4, 50, 50);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
'button4',
|
|
|
|
'triggered the button4 keybinding without NumLock');
|
|
|
|
|
|
|
|
exit_gracefully($pid);
|
|
|
|
|
2016-08-02 20:23:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
done_testing;
|