2 # vim:ts=4:sw=4:expandtab
4 # Please read the following documents before working on tests:
5 # • https://build.i3wm.org/docs/testsuite.html
8 # • https://build.i3wm.org/docs/lib-i3test.html
9 # (alternatively: perldoc ./testcases/lib/i3test.pm)
11 # • https://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)
19 use X11::XCB qw(:all);
25 my $cookie = $x->get_property(
28 $x->atom(name => '_NET_WM_STATE')->id,
29 GET_PROPERTY_TYPE_ANY,
34 my $reply = $x->get_property_reply($cookie->{sequence});
35 my $len = $reply->{length};
36 return undef if $len == 0;
38 my @atoms = unpack("L$len", $reply->{value});
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;
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 ##########################################################################
52 my $window = open_window;
54 my @state = get_wm_state($window);
55 ok((scalar grep { $_ == $wm_state_sticky } @state) > 0, 'sanity check: _NET_WM_STATE_STICKY is set');
57 cmd 'fullscreen enable';
58 @state = get_wm_state($window);
59 ok((scalar grep { $_ == $wm_state_sticky } @state) > 0, '_NET_WM_STATE_STICKY is set');
60 ok((scalar grep { $_ == $wm_state_fullscreen } @state) > 0, '_NET_WM_STATE_FULLSCREEN is set');
63 @state = get_wm_state($window);
64 ok((scalar grep { $_ == $wm_state_sticky } @state) == 0, '_NET_WM_STATE_STICKY is not set');
65 ok((scalar grep { $_ == $wm_state_fullscreen } @state) > 0, '_NET_WM_STATE_FULLSCREEN is set');
68 cmd 'fullscreen disable';
69 @state = get_wm_state($window);
70 ok((scalar grep { $_ == $wm_state_sticky } @state) > 0, '_NET_WM_STATE_STICKY is set');
71 ok((scalar grep { $_ == $wm_state_fullscreen } @state) == 0, '_NET_WM_STATE_FULLSCREEN is not set');
73 ###############################################################################
74 # _NET_WM_STATE is removed when the window is withdrawn.
75 ###############################################################################
78 $window = open_window;
80 @state = get_wm_state($window);
81 ok((scalar grep { $_ == $wm_state_sticky } @state) > 0, '_NET_WM_STATE_STICKY is set');
84 wait_for_unmap($window);
86 is(get_wm_state($window), undef, '_NET_WM_STATE is removed');
88 ##########################################################################