diff --git a/testcases/lib/i3test.pm.in b/testcases/lib/i3test.pm.in index aedaa601..0f5252a6 100644 --- a/testcases/lib/i3test.pm.in +++ b/testcases/lib/i3test.pm.in @@ -410,7 +410,7 @@ Returns the name of the output on which this workspace resides cmd 'focus output fake-1'; cmd 'workspace 1'; - is(get_output_for_workspace('1', 'fake-0', 'Workspace 1 in output fake-0'); + is(get_output_for_workspace('1'), 'fake-0', 'Workspace 1 in output fake-0'); =cut sub get_output_for_workspace { @@ -419,10 +419,12 @@ sub get_output_for_workspace { my $tree = $i3->get_tree->recv; my @outputs = @{$tree->{nodes}}; - foreach (grep { not $_->{name} =~ /^__/ } @outputs) { - my $output = $_->{name}; - foreach (grep { $_->{name} =~ "content" } @{$_->{nodes}}) { - return $output if $_->{nodes}[0]->{name} =~ $ws_name; + for my $output (@outputs) { + next if $output->{name} eq '__i3'; + # get the first CT_CON of each output + my $content = first { $_->{type} eq 'con' } @{$output->{nodes}}; + if (grep {$_->{name} eq $ws_name} @{$content->{nodes}}){ + return $output->{name}; } } }