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 # Verifies that the _NET_ACTIVE_WINDOW message only changes focus when the
18 # window is on a visible workspace.
19 # ticket #774, bug still present in commit 1e49f1b08a3035c1f238fcd6615e332216ab582e
22 sub send_net_active_window {
25 my $msg = pack "CCSLLLLLLL",
26 X11::XCB::CLIENT_MESSAGE, # response_type
29 $id, # destination window
30 $x->atom(name => '_NET_ACTIVE_WINDOW')->id,
37 $x->send_event(0, $x->get_root_window(), X11::XCB::EVENT_MASK_SUBSTRUCTURE_REDIRECT, $msg);
40 my $ws1 = fresh_workspace;
41 my $win1 = open_window;
42 my $win2 = open_window;
44 ################################################################################
45 # Ensure that the _NET_ACTIVE_WINDOW ClientMessage works when windows are visible
46 ################################################################################
48 is($x->input_focus, $win2->id, 'window 2 has focus');
50 send_net_active_window($win1->id);
52 is($x->input_focus, $win1->id, 'window 1 has focus');
54 ################################################################################
55 # Switch to a different workspace and ensure sending the _NET_ACTIVE_WINDOW
56 # ClientMessage has no effect anymore.
57 ################################################################################
59 my $ws2 = fresh_workspace;
60 my $win3 = open_window;
62 is($x->input_focus, $win3->id, 'window 3 has focus');
64 send_net_active_window($win1->id);
66 is($x->input_focus, $win3->id, 'window 3 still has focus');