]> git.sur5r.net Git - i3/i3/blob - testcases/t/253-multiple-net-wm-state-atoms.t
3790f92ddfee6ac5f98cb5b1f24235e7aaa83ec1
[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 # • https://build.i3wm.org/docs/testsuite.html
6 #   (or docs/testsuite)
7 #
8 # • https://build.i3wm.org/docs/lib-i3test.html
9 #   (alternatively: perldoc ./testcases/lib/i3test.pm)
10 #
11 # • https://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
24     my ($con) = @_; 
25     my $cookie = $x->get_property(
26         0,  
27         $con->{id},
28         $x->atom(name => '_NET_WM_STATE')->id,
29         GET_PROPERTY_TYPE_ANY,
30         0,  
31         4096
32     );  
33
34     my $reply = $x->get_property_reply($cookie->{sequence});
35     my $len = $reply->{length};
36     return undef if $len == 0;
37
38     my @atoms = unpack("L$len", $reply->{value});
39     return \@atoms;
40 }
41
42 my $wm_state_sticky = $x->atom(name => '_NET_WM_STATE_STICKY')->id;
43 my $wm_state_fullscreen = $x->atom(name => '_NET_WM_STATE_FULLSCREEN')->id;
44
45 ##########################################################################
46 # Given a sticky container, when it is fullscreened, then both wm state
47 # atoms are set. When the container is unfullscreened, then only the
48 # sticky atom is still set.
49 ##########################################################################
50
51 fresh_workspace;
52 my $window = open_window;
53 cmd 'sticky enable';
54 is_deeply(get_wm_state($window), [ $wm_state_sticky ], 'sanity check: _NET_WM_STATE_STICKY is set');
55
56 cmd 'fullscreen enable';
57 is_deeply(get_wm_state($window), [ $wm_state_sticky, $wm_state_fullscreen ],
58     'both _NET_WM_STATE_FULLSCREEN and _NET_WM_STATE_STICKY are set');
59
60 cmd 'sticky disable';
61 is_deeply(get_wm_state($window), [ $wm_state_fullscreen ], 'only _NET_WM_STATE_FULLSCREEN is set');
62
63 cmd 'sticky enable';
64 cmd 'fullscreen disable';
65 is_deeply(get_wm_state($window), [ $wm_state_sticky ], 'only _NET_WM_STATE_STICKY is set');
66
67 ###############################################################################
68 # _NET_WM_STATE is removed when the window is withdrawn.
69 ###############################################################################
70
71 fresh_workspace;
72 $window = open_window;
73 cmd 'sticky enable';
74 is_deeply(get_wm_state($window), [ $wm_state_sticky ], 'sanity check: _NET_WM_STATE_STICKY is set');
75
76 $window->unmap;
77 wait_for_unmap($window);
78
79 is(get_wm_state($window), undef, '_NET_WM_STATE is removed');
80
81 ##########################################################################
82
83 done_testing;