2015-09-14 13:34:15 +02:00
|
|
|
#!perl
|
|
|
|
# vim:ts=4:sw=4:expandtab
|
|
|
|
#
|
|
|
|
# Please read the following documents before working on tests:
|
2017-09-24 10:19:50 +02:00
|
|
|
# • https://build.i3wm.org/docs/testsuite.html
|
2015-09-14 13:34:15 +02:00
|
|
|
# (or docs/testsuite)
|
|
|
|
#
|
2017-09-24 10:19:50 +02:00
|
|
|
# • https://build.i3wm.org/docs/lib-i3test.html
|
2015-09-14 13:34:15 +02:00
|
|
|
# (alternatively: perldoc ./testcases/lib/i3test.pm)
|
|
|
|
#
|
2017-09-24 10:19:50 +02:00
|
|
|
# • https://build.i3wm.org/docs/ipc.html
|
2015-09-14 13:34:15 +02:00
|
|
|
# (or docs/ipc)
|
|
|
|
#
|
|
|
|
# • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
|
|
|
|
# (unless you are already familiar with Perl)
|
|
|
|
#
|
|
|
|
# Ticket: #1873
|
|
|
|
use i3test;
|
|
|
|
use X11::XCB qw(:all);
|
|
|
|
|
|
|
|
sub get_wm_state {
|
|
|
|
sync_with_i3;
|
|
|
|
|
2018-03-15 20:33:45 +01:00
|
|
|
my ($con) = @_;
|
2015-09-14 13:34:15 +02:00
|
|
|
my $cookie = $x->get_property(
|
2018-03-15 20:33:45 +01:00
|
|
|
0,
|
2015-09-14 13:34:15 +02:00
|
|
|
$con->{id},
|
|
|
|
$x->atom(name => '_NET_WM_STATE')->id,
|
|
|
|
GET_PROPERTY_TYPE_ANY,
|
2018-03-15 20:33:45 +01:00
|
|
|
0,
|
2015-09-14 13:34:15 +02:00
|
|
|
4096
|
2018-03-15 20:33:45 +01:00
|
|
|
);
|
2015-09-14 13:34:15 +02:00
|
|
|
|
|
|
|
my $reply = $x->get_property_reply($cookie->{sequence});
|
|
|
|
my $len = $reply->{length};
|
2016-02-07 12:08:50 +01:00
|
|
|
return undef if $len == 0;
|
2015-09-14 13:34:15 +02:00
|
|
|
|
|
|
|
my @atoms = unpack("L$len", $reply->{value});
|
2016-07-25 02:43:09 +02:00
|
|
|
return @atoms;
|
2015-09-14 13:34:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
my $wm_state_sticky = $x->atom(name => '_NET_WM_STATE_STICKY')->id;
|
|
|
|
my $wm_state_fullscreen = $x->atom(name => '_NET_WM_STATE_FULLSCREEN')->id;
|
|
|
|
|
|
|
|
##########################################################################
|
|
|
|
# Given a sticky container, when it is fullscreened, then both wm state
|
|
|
|
# atoms are set. When the container is unfullscreened, then only the
|
|
|
|
# sticky atom is still set.
|
|
|
|
##########################################################################
|
|
|
|
|
|
|
|
fresh_workspace;
|
|
|
|
my $window = open_window;
|
|
|
|
cmd 'sticky enable';
|
2016-07-25 02:43:09 +02:00
|
|
|
my @state = get_wm_state($window);
|
|
|
|
ok((scalar grep { $_ == $wm_state_sticky } @state) > 0, 'sanity check: _NET_WM_STATE_STICKY is set');
|
2015-09-14 13:34:15 +02:00
|
|
|
|
|
|
|
cmd 'fullscreen enable';
|
2016-07-25 02:43:09 +02:00
|
|
|
@state = get_wm_state($window);
|
|
|
|
ok((scalar grep { $_ == $wm_state_sticky } @state) > 0, '_NET_WM_STATE_STICKY is set');
|
|
|
|
ok((scalar grep { $_ == $wm_state_fullscreen } @state) > 0, '_NET_WM_STATE_FULLSCREEN is set');
|
2015-09-14 13:34:15 +02:00
|
|
|
|
|
|
|
cmd 'sticky disable';
|
2016-07-25 02:43:09 +02:00
|
|
|
@state = get_wm_state($window);
|
|
|
|
ok((scalar grep { $_ == $wm_state_sticky } @state) == 0, '_NET_WM_STATE_STICKY is not set');
|
|
|
|
ok((scalar grep { $_ == $wm_state_fullscreen } @state) > 0, '_NET_WM_STATE_FULLSCREEN is set');
|
2015-09-14 13:34:15 +02:00
|
|
|
|
|
|
|
cmd 'sticky enable';
|
|
|
|
cmd 'fullscreen disable';
|
2016-07-25 02:43:09 +02:00
|
|
|
@state = get_wm_state($window);
|
|
|
|
ok((scalar grep { $_ == $wm_state_sticky } @state) > 0, '_NET_WM_STATE_STICKY is set');
|
|
|
|
ok((scalar grep { $_ == $wm_state_fullscreen } @state) == 0, '_NET_WM_STATE_FULLSCREEN is not set');
|
2015-09-14 13:34:15 +02:00
|
|
|
|
2016-02-07 12:08:50 +01:00
|
|
|
###############################################################################
|
|
|
|
# _NET_WM_STATE is removed when the window is withdrawn.
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
fresh_workspace;
|
|
|
|
$window = open_window;
|
|
|
|
cmd 'sticky enable';
|
2016-07-25 02:43:09 +02:00
|
|
|
@state = get_wm_state($window);
|
|
|
|
ok((scalar grep { $_ == $wm_state_sticky } @state) > 0, '_NET_WM_STATE_STICKY is set');
|
2016-02-07 12:08:50 +01:00
|
|
|
|
|
|
|
$window->unmap;
|
|
|
|
wait_for_unmap($window);
|
|
|
|
|
|
|
|
is(get_wm_state($window), undef, '_NET_WM_STATE is removed');
|
|
|
|
|
2015-09-14 13:34:15 +02:00
|
|
|
##########################################################################
|
|
|
|
|
|
|
|
done_testing;
|