]> git.sur5r.net Git - i3/i3/blob - testcases/t/195-net-active-window.t
Merge branch 'master' into next
[i3/i3] / testcases / t / 195-net-active-window.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3 # Verifies that the _NET_ACTIVE_WINDOW message only changes focus when the
4 # window is on a visible workspace.
5 # ticket #774, bug still present in commit 1e49f1b08a3035c1f238fcd6615e332216ab582e
6 use i3test;
7
8 sub send_net_active_window {
9     my ($id) = @_;
10
11     my $msg = pack "CCSLLLLLLL",
12         X11::XCB::CLIENT_MESSAGE, # response_type
13         32, # format
14         0, # sequence
15         $id, # destination window
16         $x->atom(name => '_NET_ACTIVE_WINDOW')->id,
17         0,
18         0,
19         0,
20         0,
21         0;
22
23     $x->send_event(0, $x->get_root_window(), X11::XCB::EVENT_MASK_SUBSTRUCTURE_REDIRECT, $msg);
24 }
25
26 my $ws1 = fresh_workspace;
27 my $win1 = open_window;
28 my $win2 = open_window;
29
30 ################################################################################
31 # Ensure that the _NET_ACTIVE_WINDOW ClientMessage works when windows are visible
32 ################################################################################
33
34 is($x->input_focus, $win2->id, 'window 2 has focus');
35
36 send_net_active_window($win1->id);
37
38 is($x->input_focus, $win1->id, 'window 1 has focus');
39
40 ################################################################################
41 # Switch to a different workspace and ensure sending the _NET_ACTIVE_WINDOW
42 # ClientMessage has no effect anymore.
43 ################################################################################
44
45 my $ws2 = fresh_workspace;
46 my $win3 = open_window;
47
48 is($x->input_focus, $win3->id, 'window 3 has focus');
49
50 send_net_active_window($win1->id);
51
52 is($x->input_focus, $win3->id, 'window 3 still has focus');
53
54 done_testing;