This repository has been archived by the owner on Apr 18, 2023. It is now read-only.
/
502-focus-output.t
63 lines (45 loc) · 1.66 KB
/
502-focus-output.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!perl
# vim:ts=4:sw=4:expandtab
#
# Verifies the 'focus output' command works properly.
use i3test i3_autostart => 0;
use List::Util qw(first);
my $config = <<EOT;
# i3 config file (v4)
font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
fake-outputs 1024x768+0+0,1024x768+1024+0
EOT
my $pid = launch_with_config($config);
my $tmp = fresh_workspace;
my $i3 = i3(get_socket_path());
################################################################################
# use 'focus output' and verify that focus gets changed appropriately
################################################################################
sub focused_output {
my $tree = $i3->get_tree->recv;
my $focused = $tree->{focus}->[0];
my $output = first { $_->{id} == $focused } @{$tree->{nodes}};
return $output->{name};
}
$x->root->warp_pointer(0, 0);
sync_with_i3;
is(focused_output, 'fake-0', 'focus on first output');
cmd 'focus output right';
is(focused_output, 'fake-1', 'focus on second output');
# focus should wrap when we focus to the right again.
cmd 'focus output right';
is(focused_output, 'fake-0', 'focus on first output again');
cmd 'focus output left';
is(focused_output, 'fake-1', 'focus back on second output');
cmd 'focus output left';
is(focused_output, 'fake-0', 'focus on first output again');
cmd 'focus output up';
is(focused_output, 'fake-0', 'focus still on first output');
cmd 'focus output down';
is(focused_output, 'fake-0', 'focus still on first output');
cmd 'focus output fake-1';
is(focused_output, 'fake-1', 'focus on second output');
cmd 'focus output fake-0';
is(focused_output, 'fake-0', 'focus on first output');
exit_gracefully($pid);
done_testing;