tests: make focused_ws multi-monitor-safe, document it
This commit is contained in:
parent
6df971d5d5
commit
6e4a86b7d1
@ -383,19 +383,20 @@ sub workspace_exists {
|
|||||||
($name ~~ @{get_workspace_names()})
|
($name ~~ @{get_workspace_names()})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
=head2 focused_ws
|
||||||
|
|
||||||
|
Returns the name of the currently focused workspace.
|
||||||
|
|
||||||
|
=cut
|
||||||
sub focused_ws {
|
sub focused_ws {
|
||||||
my $i3 = i3(get_socket_path());
|
my $i3 = i3(get_socket_path());
|
||||||
my $tree = $i3->get_tree->recv;
|
my $tree = $i3->get_tree->recv;
|
||||||
my @outputs = @{$tree->{nodes}};
|
my $focused = $tree->{focus}->[0];
|
||||||
my @cons;
|
my $output = first { $_->{id} == $focused } @{$tree->{nodes}};
|
||||||
for my $output (@outputs) {
|
|
||||||
next if $output->{name} eq '__i3';
|
|
||||||
# get the first CT_CON of each output
|
|
||||||
my $content = first { $_->{type} == 2 } @{$output->{nodes}};
|
my $content = first { $_->{type} == 2 } @{$output->{nodes}};
|
||||||
my $first = first { $_->{fullscreen_mode} == 1 } @{$content->{nodes}};
|
my $first = first { $_->{fullscreen_mode} == 1 } @{$content->{nodes}};
|
||||||
return $first->{name}
|
return $first->{name}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Sends an I3_SYNC ClientMessage with a random value to the root window.
|
# Sends an I3_SYNC ClientMessage with a random value to the root window.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user