]> git.sur5r.net Git - i3/i3/blob - testcases/t/253-multiple-net-wm-state-atoms.t
0ce7f9fd5dd900e996c135332b55f47891f03107
[i3/i3] / testcases / t / 253-multiple-net-wm-state-atoms.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3 #
4 # Please read the following documents before working on tests:
5 # • http://build.i3wm.org/docs/testsuite.html
6 #   (or docs/testsuite)
7 #
8 # • http://build.i3wm.org/docs/lib-i3test.html
9 #   (alternatively: perldoc ./testcases/lib/i3test.pm)
10 #
11 # • http://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: #1873
18 use i3test;
19 use X11::XCB qw(:all);
20
21 sub get_wm_state {
22     sync_with_i3;
23     my $atom = $x->atom(name => '_NET_WM_STATE_HIDDEN');
24
25     my ($con) = @_; 
26     my $cookie = $x->get_property(
27         0,  
28         $con->{id},
29         $x->atom(name => '_NET_WM_STATE')->id,
30         GET_PROPERTY_TYPE_ANY,
31         0,  
32         4096
33     );  
34
35     my $reply = $x->get_property_reply($cookie->{sequence});
36     my $len = $reply->{length};
37     return 0 if $len == 0;
38
39     my @atoms = unpack("L$len", $reply->{value});
40     return \@atoms;
41 }
42
43 my $wm_state_sticky = $x->atom(name => '_NET_WM_STATE_STICKY')->id;
44 my $wm_state_fullscreen = $x->atom(name => '_NET_WM_STATE_FULLSCREEN')->id;
45
46 ##########################################################################
47 # Given a sticky container, when it is fullscreened, then both wm state
48 # atoms are set. When the container is unfullscreened, then only the
49 # sticky atom is still set.
50 ##########################################################################
51
52 fresh_workspace;
53 my $window = open_window;
54 cmd 'sticky enable';
55 is_deeply(get_wm_state($window), [ $wm_state_sticky ], 'sanity check: _NET_WM_STATE_STICKY is set');
56
57 cmd 'fullscreen enable';
58 is_deeply(get_wm_state($window), [ $wm_state_sticky, $wm_state_fullscreen ],
59     'both _NET_WM_STATE_FULLSCREEN and _NET_WM_STATE_STICKY are set');
60
61 cmd 'sticky disable';
62 is_deeply(get_wm_state($window), [ $wm_state_fullscreen ], 'only _NET_WM_STATE_FULLSCREEN is set');
63
64 cmd 'sticky enable';
65 cmd 'fullscreen disable';
66 is_deeply(get_wm_state($window), [ $wm_state_sticky ], 'only _NET_WM_STATE_STICKY is set');
67
68 ##########################################################################
69
70 done_testing;