2 # vim:ts=4:sw=4:expandtab
4 # Verifies the 'focus output' command works properly.
6 use i3test i3_autostart => 0;
7 use List::Util qw(first);
11 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
13 fake-outputs 1024x768+0+0,1024x768+1024+0
15 my $pid = launch_with_config($config);
17 my $tmp = fresh_workspace;
18 my $i3 = i3(get_socket_path());
20 ################################################################################
21 # use 'focus output' and verify that focus gets changed appropriately
22 ################################################################################
25 my $tree = $i3->get_tree->recv;
26 my $focused = $tree->{focus}->[0];
27 my $output = first { $_->{id} == $focused } @{$tree->{nodes}};
28 return $output->{name};
31 $x->root->warp_pointer(0, 0);
34 is(focused_output, 'fake-0', 'focus on first output');
36 cmd 'focus output right';
37 is(focused_output, 'fake-1', 'focus on second output');
39 # focus should wrap when we focus to the right again.
40 cmd 'focus output right';
41 is(focused_output, 'fake-0', 'focus on first output again');
43 cmd 'focus output left';
44 is(focused_output, 'fake-1', 'focus back on second output');
46 cmd 'focus output left';
47 is(focused_output, 'fake-0', 'focus on first output again');
49 cmd 'focus output up';
50 is(focused_output, 'fake-0', 'focus still on first output');
52 cmd 'focus output down';
53 is(focused_output, 'fake-0', 'focus still on first output');
55 cmd 'focus output fake-1';
56 is(focused_output, 'fake-1', 'focus on second output');
58 cmd 'focus output fake-0';
59 is(focused_output, 'fake-0', 'focus on first output');
61 exit_gracefully($pid);