tests: extend t/10-dock.t for top/bottom positioned dock clients by position/hint
This commit is contained in:
parent
ffc71859a3
commit
db0d66e545
|
@ -51,7 +51,7 @@ is($rect->height, 30, 'height is unchanged');
|
||||||
# check that we can find it in the layout tree at the expected position
|
# check that we can find it in the layout tree at the expected position
|
||||||
#####################################################################
|
#####################################################################
|
||||||
|
|
||||||
@docked = get_dock_clients;
|
@docked = get_dock_clients('top');
|
||||||
is(@docked, 1, 'one dock client found');
|
is(@docked, 1, 'one dock client found');
|
||||||
|
|
||||||
# verify the position/size
|
# verify the position/size
|
||||||
|
@ -62,6 +62,116 @@ 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}->{width}, $primary->rect->width, 'dock node as wide as the screen');
|
||||||
is($docknode->{rect}->{height}, 30, 'dock node has unchanged height');
|
is($docknode->{rect}->{height}, 30, 'dock node has unchanged height');
|
||||||
|
|
||||||
|
$window->destroy;
|
||||||
|
|
||||||
|
sleep 0.25;
|
||||||
|
|
||||||
|
@docked = get_dock_clients();
|
||||||
|
is(@docked, 0, 'no more dock clients');
|
||||||
|
|
||||||
|
#####################################################################
|
||||||
|
# check if it gets placed on bottom (by coordinates)
|
||||||
|
#####################################################################
|
||||||
|
|
||||||
|
$window = $x->root->create_child(
|
||||||
|
class => WINDOW_CLASS_INPUT_OUTPUT,
|
||||||
|
rect => [ 0, 1000, 30, 30],
|
||||||
|
background_color => '#FF0000',
|
||||||
|
window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'),
|
||||||
|
);
|
||||||
|
|
||||||
|
$window->map;
|
||||||
|
|
||||||
|
sleep 0.25;
|
||||||
|
|
||||||
|
my $rect = $window->rect;
|
||||||
|
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;
|
||||||
|
|
||||||
|
sleep 0.25;
|
||||||
|
|
||||||
|
@docked = get_dock_clients();
|
||||||
|
is(@docked, 0, 'no more dock clients');
|
||||||
|
|
||||||
|
#####################################################################
|
||||||
|
# check if it gets placed on bottom (by hint)
|
||||||
|
#####################################################################
|
||||||
|
|
||||||
|
$window = $x->root->create_child(
|
||||||
|
class => WINDOW_CLASS_INPUT_OUTPUT,
|
||||||
|
rect => [ 0, 1000, 30, 30],
|
||||||
|
background_color => '#FF0000',
|
||||||
|
window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'),
|
||||||
|
);
|
||||||
|
|
||||||
|
$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;
|
||||||
|
|
||||||
|
sleep 0.25;
|
||||||
|
|
||||||
|
@docked = get_dock_clients('top');
|
||||||
|
is(@docked, 1, 'dock client on top');
|
||||||
|
|
||||||
|
$window->destroy;
|
||||||
|
|
||||||
|
sleep 0.25;
|
||||||
|
|
||||||
|
@docked = get_dock_clients();
|
||||||
|
is(@docked, 0, 'no more dock clients');
|
||||||
|
|
||||||
|
$window = $x->root->create_child(
|
||||||
|
class => WINDOW_CLASS_INPUT_OUTPUT,
|
||||||
|
rect => [ 0, 1000, 30, 30],
|
||||||
|
background_color => '#FF0000',
|
||||||
|
window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'),
|
||||||
|
);
|
||||||
|
|
||||||
|
$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, 0, 16, 0, 0, 0, 0, 0, 1280, 0, 0)
|
||||||
|
);
|
||||||
|
|
||||||
|
$window->map;
|
||||||
|
|
||||||
|
sleep 0.25;
|
||||||
|
|
||||||
|
@docked = get_dock_clients('bottom');
|
||||||
|
is(@docked, 1, 'dock client on bottom');
|
||||||
|
|
||||||
|
$window->destroy;
|
||||||
|
|
||||||
|
|
||||||
#####################################################################
|
#####################################################################
|
||||||
# regression test: transient dock client
|
# regression test: transient dock client
|
||||||
#####################################################################
|
#####################################################################
|
||||||
|
|
|
@ -8,6 +8,7 @@ use X11::XCB::Window;
|
||||||
use X11::XCB qw(:all);
|
use X11::XCB qw(:all);
|
||||||
use AnyEvent::I3;
|
use AnyEvent::I3;
|
||||||
use List::Util qw(first);
|
use List::Util qw(first);
|
||||||
|
use List::MoreUtils qw(lastval);
|
||||||
use v5.10;
|
use v5.10;
|
||||||
|
|
||||||
use Exporter ();
|
use Exporter ();
|
||||||
|
@ -130,14 +131,24 @@ sub get_focused {
|
||||||
}
|
}
|
||||||
|
|
||||||
sub get_dock_clients {
|
sub get_dock_clients {
|
||||||
|
my $which = shift;
|
||||||
|
|
||||||
my $tree = i3("/tmp/nestedcons")->get_tree->recv;
|
my $tree = i3("/tmp/nestedcons")->get_tree->recv;
|
||||||
my @outputs = @{$tree->{nodes}};
|
my @outputs = @{$tree->{nodes}};
|
||||||
# Children of all dockareas
|
# Children of all dockareas
|
||||||
my @docked;
|
my @docked;
|
||||||
for my $output (@outputs) {
|
for my $output (@outputs) {
|
||||||
|
if (!defined($which)) {
|
||||||
@docked = (@docked, map { @{$_->{nodes}} }
|
@docked = (@docked, map { @{$_->{nodes}} }
|
||||||
grep { $_->{type} == 5 }
|
grep { $_->{type} == 5 }
|
||||||
@{$output->{nodes}});
|
@{$output->{nodes}});
|
||||||
|
} elsif ($which eq 'top') {
|
||||||
|
my $first = first { $_->{type} == 5 } @{$output->{nodes}};
|
||||||
|
@docked = (@docked, @{$first->{nodes}});
|
||||||
|
} elsif ($which eq 'bottom') {
|
||||||
|
my $last = lastval { $_->{type} == 5 } @{$output->{nodes}};
|
||||||
|
@docked = (@docked, @{$last->{nodes}});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return @docked;
|
return @docked;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue