]> git.sur5r.net Git - i3/i3/blob - testcases/t/158-wm_take_focus.t
Merge branch 'fix-mark'
[i3/i3] / testcases / t / 158-wm_take_focus.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3 #
4 # Tests if the WM_TAKE_FOCUS protocol is correctly handled by i3
5 #
6 use X11::XCB qw(:all);
7 use i3test;
8 use v5.10;
9
10 my $x = X11::XCB::Connection->new;
11
12 subtest 'Window without WM_TAKE_FOCUS', sub {
13     fresh_workspace;
14
15     my $window = open_window($x);
16
17     ok(!wait_for_event($x, 1, sub { $_[0]->{response_type} == 161 }), 'did not receive ClientMessage');
18
19     done_testing;
20 };
21
22 subtest 'Window with WM_TAKE_FOCUS', sub {
23     fresh_workspace;
24
25     my $take_focus = $x->atom(name => 'WM_TAKE_FOCUS');
26
27     my $window = open_window($x, {
28         dont_map => 1,
29         protocols => [ $take_focus ],
30     });
31
32     $window->map;
33
34     ok(wait_for_event($x, 1, sub {
35         return 0 unless $_[0]->{response_type} == 161;
36         my ($data, $time) = unpack("L2", $_[0]->{data});
37         return ($data == $take_focus->id);
38     }), 'got ClientMessage with WM_TAKE_FOCUS atom');
39
40     done_testing;
41 };
42
43
44 done_testing;