2009-08-21 12:32:54 +02:00
|
|
|
#!perl
|
|
|
|
# vim:ts=4:sw=4:expandtab
|
|
|
|
|
2011-02-21 00:23:25 +01:00
|
|
|
use i3test;
|
2009-08-21 12:32:54 +02:00
|
|
|
use X11::XCB qw(:all);
|
|
|
|
use Time::HiRes qw(sleep);
|
2009-08-21 15:01:20 +02:00
|
|
|
use List::Util qw(first);
|
2009-08-21 12:32:54 +02:00
|
|
|
|
|
|
|
BEGIN {
|
|
|
|
use_ok('X11::XCB::Connection') or BAIL_OUT('Cannot load X11::XCB::Connection');
|
|
|
|
}
|
|
|
|
|
2009-10-26 20:04:37 +01:00
|
|
|
my $x = X11::XCB::Connection->new;
|
2011-02-21 00:23:25 +01:00
|
|
|
my $i3 = i3("/tmp/nestedcons");
|
|
|
|
|
|
|
|
#####################################################################
|
|
|
|
# verify that there is no dock window yet
|
|
|
|
#####################################################################
|
|
|
|
|
|
|
|
my $tree = $i3->get_tree->recv;
|
|
|
|
my @outputs = @{$tree->{nodes}};
|
|
|
|
# Children of all dockareas
|
|
|
|
my @docked;
|
|
|
|
for my $output (@outputs) {
|
|
|
|
@docked = (@docked, map { @{$_->{nodes}} }
|
|
|
|
grep { $_->{type} == 5 }
|
|
|
|
@{$output->{nodes}});
|
|
|
|
}
|
|
|
|
|
|
|
|
is(@docked, 0, 'no dock clients yet');
|
2009-08-21 12:32:54 +02:00
|
|
|
|
|
|
|
#####################################################################
|
|
|
|
# Create a dock window and see if it gets managed
|
|
|
|
#####################################################################
|
|
|
|
|
2009-10-26 20:04:37 +01:00
|
|
|
my $screens = $x->screens;
|
2009-08-21 15:01:20 +02:00
|
|
|
|
|
|
|
# Get the primary screen
|
|
|
|
my $primary = first { $_->primary } @{$screens};
|
|
|
|
|
|
|
|
# TODO: focus the primary screen before
|
|
|
|
|
2009-10-26 20:04:37 +01:00
|
|
|
my $window = $x->root->create_child(
|
2009-08-21 12:32:54 +02:00
|
|
|
class => WINDOW_CLASS_INPUT_OUTPUT,
|
|
|
|
rect => [ 0, 0, 30, 30],
|
2009-08-21 16:06:12 +02:00
|
|
|
background_color => '#FF0000',
|
2011-02-20 23:50:01 +01:00
|
|
|
window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'),
|
2009-08-21 12:32:54 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
$window->map;
|
|
|
|
|
|
|
|
sleep 0.25;
|
|
|
|
|
2009-08-21 15:01:20 +02:00
|
|
|
my $rect = $window->rect;
|
|
|
|
is($rect->width, $primary->rect->width, 'dock client is as wide as the screen');
|
2011-02-21 00:23:25 +01:00
|
|
|
is($rect->height, 30, 'height is unchanged');
|
|
|
|
|
|
|
|
#####################################################################
|
|
|
|
# check that we can find it in the layout tree at the expected position
|
|
|
|
#####################################################################
|
|
|
|
|
|
|
|
$tree = $i3->get_tree->recv;
|
|
|
|
@outputs = @{$tree->{nodes}};
|
|
|
|
@docked;
|
|
|
|
for my $output (@outputs) {
|
|
|
|
@docked = (@docked, map { @{$_->{nodes}} }
|
|
|
|
grep { $_->{type} == 5 }
|
|
|
|
@{$output->{nodes}});
|
|
|
|
}
|
|
|
|
|
|
|
|
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');
|
|
|
|
|
|
|
|
#####################################################################
|
|
|
|
# regression test: transient dock client
|
|
|
|
#####################################################################
|
2009-08-21 12:32:54 +02:00
|
|
|
|
2010-01-01 16:19:55 +01:00
|
|
|
my $fwindow = $x->root->create_child(
|
|
|
|
class => WINDOW_CLASS_INPUT_OUTPUT,
|
|
|
|
rect => [ 0, 0, 30, 30],
|
|
|
|
background_color => '#FF0000',
|
2011-02-20 23:50:01 +01:00
|
|
|
window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'),
|
2010-01-01 16:19:55 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
$fwindow->transient_for($window);
|
|
|
|
$fwindow->map;
|
|
|
|
|
|
|
|
sleep 0.25;
|
|
|
|
|
2011-02-21 00:23:25 +01:00
|
|
|
does_i3_live;
|
2010-01-01 16:19:55 +01:00
|
|
|
|
2011-02-21 00:23:25 +01:00
|
|
|
done_testing;
|