2009-08-21 06:32:54 -04:00
|
|
|
#!perl
|
|
|
|
# vim:ts=4:sw=4:expandtab
|
2012-09-10 08:09:01 -04:00
|
|
|
#
|
|
|
|
# Please read the following documents before working on tests:
|
|
|
|
# • http://build.i3wm.org/docs/testsuite.html
|
|
|
|
# (or docs/testsuite)
|
|
|
|
#
|
|
|
|
# • http://build.i3wm.org/docs/lib-i3test.html
|
|
|
|
# (alternatively: perldoc ./testcases/lib/i3test.pm)
|
|
|
|
#
|
|
|
|
# • http://build.i3wm.org/docs/ipc.html
|
|
|
|
# (or docs/ipc)
|
|
|
|
#
|
|
|
|
# • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
|
|
|
|
# (unless you are already familiar with Perl)
|
2009-08-21 06:32:54 -04:00
|
|
|
|
2011-02-20 18:23:25 -05:00
|
|
|
use i3test;
|
2011-11-21 15:39:50 -05:00
|
|
|
use X11::XCB 'PROP_MODE_REPLACE';
|
2009-08-21 09:01:20 -04:00
|
|
|
use List::Util qw(first);
|
2009-08-21 06:32:54 -04:00
|
|
|
|
2011-02-20 18:23:25 -05:00
|
|
|
#####################################################################
|
|
|
|
# verify that there is no dock window yet
|
|
|
|
#####################################################################
|
|
|
|
|
|
|
|
# Children of all dockareas
|
2011-02-21 06:21:02 -05:00
|
|
|
my @docked = get_dock_clients;
|
2011-02-20 18:23:25 -05:00
|
|
|
is(@docked, 0, 'no dock clients yet');
|
2009-08-21 06:32:54 -04:00
|
|
|
|
|
|
|
#####################################################################
|
|
|
|
# Create a dock window and see if it gets managed
|
|
|
|
#####################################################################
|
|
|
|
|
2009-10-26 15:04:37 -04:00
|
|
|
my $screens = $x->screens;
|
2009-08-21 09:01:20 -04:00
|
|
|
|
|
|
|
# Get the primary screen
|
|
|
|
my $primary = first { $_->primary } @{$screens};
|
|
|
|
|
|
|
|
# TODO: focus the primary screen before
|
2011-11-21 18:47:32 -05:00
|
|
|
my $window = open_window({
|
2011-09-24 10:11:37 -04:00
|
|
|
window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'),
|
|
|
|
});
|
2009-08-21 06:32:54 -04:00
|
|
|
|
2009-08-21 09:01:20 -04:00
|
|
|
my $rect = $window->rect;
|
|
|
|
is($rect->width, $primary->rect->width, 'dock client is as wide as the screen');
|
2011-02-20 18:23:25 -05:00
|
|
|
is($rect->height, 30, 'height is unchanged');
|
|
|
|
|
|
|
|
#####################################################################
|
|
|
|
# check that we can find it in the layout tree at the expected position
|
|
|
|
#####################################################################
|
|
|
|
|
2011-02-21 08:55:03 -05:00
|
|
|
@docked = get_dock_clients('top');
|
2011-02-20 18:23:25 -05:00
|
|
|
is(@docked, 1, 'one dock client found');
|
|
|
|
|
|
|
|
# verify the position/size
|
|
|
|
my $docknode = $docked[0];
|
|
|
|
|
|
|
|
is($docknode->{rect}->{x}, 0, 'dock node placed at x=0');
|
|
|
|
is($docknode->{rect}->{y}, 0, 'dock node placed at y=0');
|
|
|
|
is($docknode->{rect}->{width}, $primary->rect->width, 'dock node as wide as the screen');
|
|
|
|
is($docknode->{rect}->{height}, 30, 'dock node has unchanged height');
|
|
|
|
|
2011-08-27 07:47:10 -04:00
|
|
|
#####################################################################
|
|
|
|
# check that re-configuring the height works
|
|
|
|
#####################################################################
|
|
|
|
|
|
|
|
$window->rect(X11::XCB::Rect->new(x => 0, y => 0, width => 50, height => 40));
|
|
|
|
|
2011-11-21 19:13:37 -05:00
|
|
|
sync_with_i3;
|
2011-08-27 07:47:10 -04:00
|
|
|
|
|
|
|
@docked = get_dock_clients('top');
|
|
|
|
is(@docked, 1, 'one dock client found');
|
|
|
|
|
|
|
|
# verify the position/size
|
|
|
|
$docknode = $docked[0];
|
|
|
|
|
|
|
|
is($docknode->{rect}->{x}, 0, 'dock node placed at x=0');
|
|
|
|
is($docknode->{rect}->{y}, 0, 'dock node placed at y=0');
|
|
|
|
is($docknode->{rect}->{width}, $primary->rect->width, 'dock node as wide as the screen');
|
|
|
|
is($docknode->{rect}->{height}, 40, 'dock height changed');
|
|
|
|
|
2011-02-21 08:55:03 -05:00
|
|
|
$window->destroy;
|
|
|
|
|
2011-11-21 17:44:20 -05:00
|
|
|
wait_for_unmap $window;
|
2011-02-21 08:55:03 -05:00
|
|
|
|
|
|
|
@docked = get_dock_clients();
|
|
|
|
is(@docked, 0, 'no more dock clients');
|
|
|
|
|
|
|
|
#####################################################################
|
|
|
|
# check if it gets placed on bottom (by coordinates)
|
|
|
|
#####################################################################
|
|
|
|
|
2011-11-21 18:47:32 -05:00
|
|
|
$window = open_window({
|
2011-09-24 10:11:37 -04:00
|
|
|
rect => [ 0, 1000, 30, 30 ],
|
|
|
|
background_color => '#FF0000',
|
|
|
|
window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'),
|
|
|
|
});
|
2011-02-21 08:55:03 -05:00
|
|
|
|
2011-11-21 15:04:00 -05:00
|
|
|
$rect = $window->rect;
|
2011-02-21 08:55:03 -05:00
|
|
|
is($rect->width, $primary->rect->width, 'dock client is as wide as the screen');
|
|
|
|
is($rect->height, 30, 'height is unchanged');
|
|
|
|
|
|
|
|
@docked = get_dock_clients('bottom');
|
|
|
|
is(@docked, 1, 'dock client on bottom');
|
|
|
|
|
|
|
|
$window->destroy;
|
|
|
|
|
2011-11-21 17:44:20 -05:00
|
|
|
wait_for_unmap $window;
|
2011-02-21 08:55:03 -05:00
|
|
|
|
|
|
|
@docked = get_dock_clients();
|
|
|
|
is(@docked, 0, 'no more dock clients');
|
|
|
|
|
|
|
|
#####################################################################
|
|
|
|
# check if it gets placed on bottom (by hint)
|
|
|
|
#####################################################################
|
|
|
|
|
2011-11-21 18:47:32 -05:00
|
|
|
$window = open_window({
|
2011-09-24 10:11:37 -04:00
|
|
|
dont_map => 1,
|
|
|
|
rect => [ 0, 1000, 30, 30 ],
|
|
|
|
background_color => '#FF0000',
|
|
|
|
window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'),
|
|
|
|
});
|
2011-02-21 08:55:03 -05:00
|
|
|
|
|
|
|
$window->_create();
|
|
|
|
|
|
|
|
# Add a _NET_WM_STRUT_PARTIAL hint
|
|
|
|
my $atomname = $x->atom(name => '_NET_WM_STRUT_PARTIAL');
|
|
|
|
my $atomtype = $x->atom(name => 'CARDINAL');
|
|
|
|
|
|
|
|
$x->change_property(
|
|
|
|
PROP_MODE_REPLACE,
|
|
|
|
$window->id,
|
|
|
|
$atomname->id,
|
|
|
|
$atomtype->id,
|
|
|
|
32, # 32 bit integer
|
|
|
|
12,
|
|
|
|
pack('L12', 0, 0, 16, 0, 0, 0, 0, 0, 0, 1280, 0, 0)
|
|
|
|
);
|
|
|
|
|
|
|
|
$window->map;
|
|
|
|
|
2011-11-21 17:44:20 -05:00
|
|
|
wait_for_map $window;
|
2011-02-21 08:55:03 -05:00
|
|
|
|
|
|
|
@docked = get_dock_clients('top');
|
|
|
|
is(@docked, 1, 'dock client on top');
|
|
|
|
|
2015-03-25 19:45:42 -04:00
|
|
|
# now change strut_partial to reserve space on the bottom and the dock should
|
|
|
|
# be moved to the bottom dock area
|
|
|
|
$x->change_property(
|
|
|
|
PROP_MODE_REPLACE,
|
|
|
|
$window->id,
|
|
|
|
$atomname->id,
|
|
|
|
$atomtype->id,
|
|
|
|
32, # 32 bit integer
|
|
|
|
12,
|
|
|
|
pack('L12', 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 1280, 0)
|
|
|
|
);
|
|
|
|
|
|
|
|
sync_with_i3;
|
|
|
|
@docked = get_dock_clients('bottom');
|
|
|
|
is(@docked, 1, 'dock client on bottom');
|
|
|
|
|
2011-02-21 08:55:03 -05:00
|
|
|
$window->destroy;
|
|
|
|
|
2011-11-21 17:44:20 -05:00
|
|
|
wait_for_unmap $window;
|
2011-02-21 08:55:03 -05:00
|
|
|
|
|
|
|
@docked = get_dock_clients();
|
|
|
|
is(@docked, 0, 'no more dock clients');
|
|
|
|
|
2011-11-21 18:47:32 -05:00
|
|
|
$window = open_window({
|
2011-09-24 10:11:37 -04:00
|
|
|
dont_map => 1,
|
|
|
|
rect => [ 0, 1000, 30, 30 ],
|
|
|
|
background_color => '#FF0000',
|
|
|
|
window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'),
|
|
|
|
});
|
2011-02-21 08:55:03 -05:00
|
|
|
|
|
|
|
$window->_create();
|
|
|
|
|
|
|
|
# Add a _NET_WM_STRUT_PARTIAL hint
|
2011-11-21 15:04:00 -05:00
|
|
|
$atomname = $x->atom(name => '_NET_WM_STRUT_PARTIAL');
|
|
|
|
$atomtype = $x->atom(name => 'CARDINAL');
|
2011-02-21 08:55:03 -05:00
|
|
|
|
|
|
|
$x->change_property(
|
|
|
|
PROP_MODE_REPLACE,
|
|
|
|
$window->id,
|
|
|
|
$atomname->id,
|
|
|
|
$atomtype->id,
|
|
|
|
32, # 32 bit integer
|
|
|
|
12,
|
|
|
|
pack('L12', 0, 0, 0, 16, 0, 0, 0, 0, 0, 1280, 0, 0)
|
|
|
|
);
|
|
|
|
|
|
|
|
$window->map;
|
|
|
|
|
2011-11-21 17:44:20 -05:00
|
|
|
wait_for_map $window;
|
2011-02-21 08:55:03 -05:00
|
|
|
|
|
|
|
@docked = get_dock_clients('bottom');
|
|
|
|
is(@docked, 1, 'dock client on bottom');
|
|
|
|
|
|
|
|
$window->destroy;
|
|
|
|
|
|
|
|
|
2011-02-20 18:23:25 -05:00
|
|
|
#####################################################################
|
|
|
|
# regression test: transient dock client
|
|
|
|
#####################################################################
|
2009-08-21 06:32:54 -04:00
|
|
|
|
2011-11-21 18:47:32 -05:00
|
|
|
my $fwindow = open_window({
|
2011-09-24 10:11:37 -04:00
|
|
|
dont_map => 1,
|
|
|
|
background_color => '#FF0000',
|
|
|
|
window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'),
|
|
|
|
});
|
2010-01-01 10:19:55 -05:00
|
|
|
|
|
|
|
$fwindow->transient_for($window);
|
|
|
|
$fwindow->map;
|
|
|
|
|
2011-11-21 17:44:20 -05:00
|
|
|
wait_for_map $fwindow;
|
2010-01-01 10:19:55 -05:00
|
|
|
|
2011-02-20 18:23:25 -05:00
|
|
|
does_i3_live;
|
2010-01-01 10:19:55 -05:00
|
|
|
|
2011-02-20 18:23:25 -05:00
|
|
|
done_testing;
|