]> git.sur5r.net Git - i3/i3/blob - testcases/t/527-focus-fallback.t
Merge pull request #3215 from orestisf1993/focus-next-prev
[i3/i3] / testcases / t / 527-focus-fallback.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 # Ticket: #1378
18 use i3test;
19 use X11::XCB qw(:all);
20
21 sub get_ewmh_window {
22     my $cookie = $x->get_property(
23         0,
24         $x->get_root_window(),
25         $x->atom(name => '_NET_SUPPORTING_WM_CHECK')->id,
26         $x->atom(name => 'WINDOW')->id,
27         0,
28         4096
29     );
30
31     my $reply = $x->get_property_reply($cookie->{sequence});
32     my $len = $reply->{length};
33     return undef if $len == 0;
34
35     return unpack("L", $reply->{value});
36 }
37
38 my $window = open_window;
39 sync_with_i3;
40 is($x->input_focus, $window->id, 'sanity check: window has input focus');
41 cmd 'kill';
42 sync_with_i3;
43 is($x->input_focus, get_ewmh_window(), 'focus falls back to the EWMH window');
44
45 done_testing;