aboutsummaryrefslogtreecommitdiff
path: root/testcases/t/257-keypress-group1-fallback.t
blob: 6a1bc73a919ebed6746c3d2190a0ed785f5ca181 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!perl
# vim:ts=4:sw=4:expandtab
#
# Please read the following documents before working on tests:
# • https://build.i3wm.org/docs/testsuite.html
#   (or docs/testsuite)
#
# • https://build.i3wm.org/docs/lib-i3test.html
#   (alternatively: perldoc ./testcases/lib/i3test.pm)
#
# • https://build.i3wm.org/docs/ipc.html
#   (or docs/ipc)
#
# • https://i3wm.org/downloads/modern_perl_a4.pdf
#   (unless you are already familiar with Perl)
#
# Verifies that when using multiple keyboard layouts at the same time, bindings
# without a specified XKB group will work in all XKB groups.
# Ticket: #2062
# Bug still in: 4.11-103-gc8d51b4
# Bug introduced with commit 0e5180cae9e9295678e3f053042b559e82cb8c98
use i3test
    i3_config => <<EOT;
# i3 config file (v4)
font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1

bindsym Print nop Print
bindsym Mod4+Return nop Mod4+Return
EOT
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');
    skip "setxkbmap not found", 1 if
        system(q|setxkbmap -print >/dev/null|) != 0;

system(q|setxkbmap us,ru -option grp:alt_shift_toggle|);

is(listen_for_binding(
    sub {
        xtest_key_press(107);
        xtest_key_release(107);
        xtest_sync_with_i3;
    },
    ),
   'Print',
   'triggered the "Print" keybinding');

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
        xtest_sync_with_i3;
    },
    ),
   'Mod4+Return',
   'triggered the "Mod4+Return" keybinding');

# Switch keyboard group to russian.
set_xkb_group(1);

is(listen_for_binding(
    sub {
        xtest_key_press(107);
        xtest_key_release(107);
        xtest_sync_with_i3;
    },
    ),
   'Print',
   'triggered the "Print" keybinding');

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
        xtest_sync_with_i3;
    },
    ),
   'Mod4+Return',
   'triggered the "Mod4+Return" keybinding');

# Disable the grp:alt_shift_toggle option, as we use Alt+Shift in other testcases.
system(q|setxkbmap us -option|);

}

done_testing;