]> git.sur5r.net Git - i3/i3/blob - testcases/t/258-keypress-release.t
614164abf89cb381b82994c8252fb9f5d5e846c7
[i3/i3] / testcases / t / 258-keypress-release.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3 #
4 # Please read the following documents before working on tests:
5 # • https://build.i3wm.org/docs/testsuite.html
6 #   (or docs/testsuite)
7 #
8 # • https://build.i3wm.org/docs/lib-i3test.html
9 #   (alternatively: perldoc ./testcases/lib/i3test.pm)
10 #
11 # • https://build.i3wm.org/docs/ipc.html
12 #   (or docs/ipc)
13 #
14 # • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
15 #   (unless you are already familiar with Perl)
16 #
17 # Verifies that --release key bindings are not shadowed by non-release key
18 # bindings for the same key.
19 # Ticket: #2002
20 # Bug still in: 4.11-103-gc8d51b4
21 # Bug introduced with commit bf3cd41b5ddf1e757515ab5fbf811be56e5f69cc
22 use i3test i3_config => <<EOT;
23 # i3 config file (v4)
24 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
25
26 bindsym Print nop Print
27 bindsym --release Control+Print nop Control+Print
28
29 # see issue #2442
30 bindsym Mod1+b nop Mod1+b
31 bindsym --release Mod1+Shift+b nop Mod1+Shift+b release
32
33 bindsym --release Shift+x nop Shift+x
34
35 # see issue #2733
36 # 133 == Mod4
37 bindcode 133 nop 133
38 bindcode --release 133 nop 133 release
39
40 mode "a_mode" {
41     # 27 == r
42     bindcode 27 --release mode "default"
43 }
44 bindsym Mod1+r mode "a_mode"
45 bindcode 27 nop do not receive
46 EOT
47 use i3test::XTEST;
48 use ExtUtils::PkgConfig;
49
50 SKIP: {
51     skip "libxcb-xkb too old (need >= 1.11)", 1 unless
52         ExtUtils::PkgConfig->atleast_version('xcb-xkb', '1.11');
53
54 is(listen_for_binding(
55     sub {
56         xtest_key_press(107); # Print
57         xtest_key_release(107); # Print
58         xtest_sync_with_i3;
59     },
60     ),
61     'Print',
62     'triggered the "Print" keybinding');
63
64 is(listen_for_binding(
65     sub {
66         xtest_key_press(37); # Control_L
67         xtest_key_press(107); # Print
68         xtest_key_release(107); # Print
69         xtest_key_release(37); # Control_L
70         xtest_sync_with_i3;
71     },
72     ),
73     'Control+Print',
74     'triggered the "Control+Print" keybinding');
75
76 is(listen_for_binding(
77     sub {
78         xtest_key_press(64); # Alt_L
79         xtest_key_press(56); # b
80         xtest_key_release(56); # b
81         xtest_key_release(64); # Alt_L
82         xtest_sync_with_i3;
83     },
84     ),
85     'Mod1+b',
86     'triggered the "Mod1+b" keybinding');
87
88 is(listen_for_binding(
89     sub {
90         xtest_key_press(64); # Alt_L
91         xtest_key_press(50); # Shift_L
92         xtest_key_press(56); # b
93         xtest_key_release(56); # b
94         xtest_key_release(50); # Shift_L
95         xtest_key_release(64); # Alt_L
96         xtest_sync_with_i3;
97     },
98     ),
99     'Mod1+Shift+b release',
100     'triggered the "Mod1+Shift+b" release keybinding');
101
102 is(listen_for_binding(
103         sub {
104             xtest_key_press(50); # Shift
105             xtest_key_press(53); # x
106             xtest_key_release(53); # x
107             xtest_key_release(50); # Shift
108             xtest_sync_with_i3;
109         },
110         ),
111        'Shift+x',
112        'triggered the "Shift+x" keybinding by releasing x first');
113
114 is(listen_for_binding(
115         sub {
116             xtest_key_press(50); # Shift
117             xtest_key_press(53); # x
118             xtest_key_release(50); # Shift
119             xtest_key_release(53);  # x
120             xtest_sync_with_i3;
121         },
122         ),
123        'Shift+x',
124        'triggered the "Shift+x" keybinding by releasing Shift first');
125
126 is(listen_for_binding(
127     sub {
128         xtest_key_press(133);
129         xtest_sync_with_i3;
130     },
131     ),
132     '133',
133     'triggered the 133 keycode press binding');
134
135 is(listen_for_binding(
136     sub {
137         xtest_key_release(133);
138         xtest_sync_with_i3;
139     },
140     ),
141     '133 release',
142     'triggered the 133 keycode release binding');
143
144 for my $i (1 .. 2) {
145     is(listen_for_binding(
146         sub {
147             xtest_key_press(64); # Alt_l
148             xtest_key_press(27); # r
149             xtest_key_release(27); # r
150             xtest_key_release(64); # Alt_l
151             xtest_sync_with_i3;
152         },
153         ),
154         'mode "a_mode"',
155         "switched to mode \"a_mode\" $i/2");
156
157     is(listen_for_binding(
158         sub {
159             xtest_key_press(27); # r
160             xtest_key_release(27); # r
161             xtest_sync_with_i3;
162         },
163         ),
164         'mode "default"',
165         "switched back to default $i/2");
166 }
167
168 }
169
170 done_testing;