2 # vim:ts=4:sw=4:expandtab
4 # Please read the following documents before working on tests:
5 # • http://build.i3wm.org/docs/testsuite.html
8 # • http://build.i3wm.org/docs/lib-i3test.html
9 # (alternatively: perldoc ./testcases/lib/i3test.pm)
11 # • http://build.i3wm.org/docs/ipc.html
14 # • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
15 # (unless you are already familiar with Perl)
17 # Tests if the WM_TAKE_FOCUS protocol is correctly handled by i3
21 subtest 'Window without WM_TAKE_FOCUS', sub {
24 my $window = open_window;
25 # sync_with_i3 will send a ClientMessage to i3 and receive one targeted to
26 # $window->id. If it receives WM_TAKE_FOCUS instead, it will return 0, thus
28 ok(sync_with_i3(window_id => $window->id), 'did not receive ClientMessage');
33 subtest 'Window with WM_TAKE_FOCUS', sub {
36 my $take_focus = $x->atom(name => 'WM_TAKE_FOCUS');
38 my $window = open_window({
40 protocols => [ $take_focus ],
45 ok(wait_for_event(1, sub {
46 return 0 unless $_[0]->{response_type} == 161;
47 my ($data, $time) = unpack("L2", $_[0]->{data});
48 return ($data == $take_focus->id);
49 }), 'got ClientMessage with WM_TAKE_FOCUS atom');