tests: extend t/10-dock.t for top/bottom positioned dock clients by position/hint

This commit is contained in:
Michael Stapelberg
2011-02-21 14:55:03 +01:00
parent ffc71859a3
commit db0d66e545
2 changed files with 125 additions and 4 deletions

View File

@ -8,6 +8,7 @@ use X11::XCB::Window;
use X11::XCB qw(:all);
use AnyEvent::I3;
use List::Util qw(first);
use List::MoreUtils qw(lastval);
use v5.10;
use Exporter ();
@ -130,14 +131,24 @@ sub get_focused {
}
sub get_dock_clients {
my $which = shift;
my $tree = i3("/tmp/nestedcons")->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}});
if (!defined($which)) {
@docked = (@docked, map { @{$_->{nodes}} }
grep { $_->{type} == 5 }
@{$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;
}