2 # vim:ts=4:sw=4:expandtab
4 # Please read the following documents before working on tests:
5 # • http://build.i3wm.org/docs/testsuite.html
8 # • http://build.i3wm.org/docs/lib-i3test.html
9 # (alternatively: perldoc ./testcases/lib/i3test.pm)
11 # • http://build.i3wm.org/docs/ipc.html
14 # • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
15 # (unless you are already familiar with Perl)
17 # Verifies that focus output right works with monitor setups that don’t line up
18 # on their x/y coordinates.
20 # ticket #771, bug still present in commit dd743f3b55b2f86d9f1f69ef7952ae8ece4de504
22 use i3test i3_autostart => 0;
24 sub test_focus_left_right {
27 my $pid = launch_with_config($config);
29 my $i3 = i3(get_socket_path(0));
31 $x->root->warp_pointer(0, 0);
34 ############################################################################
35 # Ensure that moving left and right works.
36 ############################################################################
38 # First ensure both workspaces have something to focus
40 my $left_win = open_window;
43 my $right_win = open_window;
45 is($x->input_focus, $right_win->id, 'right window focused');
47 cmd "focus output left";
48 is($x->input_focus, $left_win->id, 'left window focused');
50 cmd "focus output right";
51 is($x->input_focus, $right_win->id, 'right window focused');
53 cmd "focus output right";
54 is($x->input_focus, $left_win->id, 'left window focused (wrapping)');
56 cmd "focus output left";
57 is($x->input_focus, $right_win->id, 'right window focused (wrapping)');
59 ############################################################################
60 # Ensure that moving down from S0 doesn’t crash i3.
61 ############################################################################
63 my $second = fresh_workspace(output => 1);
65 cmd "focus output down";
69 exit_gracefully($pid);
72 # Screen setup looks like this:
81 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
83 fake-outputs 1080x1920+0+0,1920x1080+1080+500
86 test_focus_left_right($config);
88 # Screen setup looks like this:
97 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
99 fake-outputs 1080x1920+0+0,1920x200+1080+0
102 test_focus_left_right($config);
104 # Screen setup looks like this:
112 # i3 config file (v4)
113 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
115 fake-outputs 1080x1920+0+0,1920x200+1080+1720
118 test_focus_left_right($config);
120 # Screen setup looks like this:
123 # | S1 |--------+ S3 |
125 # +----+--------+----+
128 # i3 config file (v4)
129 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
131 fake-outputs 1080x1920+0+0,1920x200+1080+1720,1080x1920+1280+0
134 my $pid = launch_with_config($config);
136 my $i3 = i3(get_socket_path(0));
138 $x->root->warp_pointer(0, 0);
141 ############################################################################
142 # Ensure that focusing right/left works in the expected order.
143 ############################################################################
145 sub get_focused_output {
146 my $tree = i3(get_socket_path())->get_tree->recv;
147 my ($focused_id) = @{$tree->{focus}};
148 my ($output) = grep { $_->{id} == $focused_id } @{$tree->{nodes}};
149 return $output->{name};
152 is(get_focused_output(), 'fake-0', 'focus on fake-0');
154 cmd 'focus output right';
155 is(get_focused_output(), 'fake-1', 'focus on fake-1');
157 cmd 'focus output right';
158 is(get_focused_output(), 'fake-2', 'focus on fake-2');
160 cmd 'focus output left';
161 is(get_focused_output(), 'fake-1', 'focus on fake-1');
163 cmd 'focus output left';
164 is(get_focused_output(), 'fake-0', 'focus on fake-0');
166 cmd 'focus output left';
167 is(get_focused_output(), 'fake-2', 'focus on fake-2 (wrapping)');
169 cmd 'focus output right';
170 is(get_focused_output(), 'fake-0', 'focus on fake-0 (wrapping)');
172 exit_gracefully($pid);