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/up from S0 doesn’t crash i3 and is a no-op.
61 ############################################################################
63 my $second = fresh_workspace(output => 1);
64 my $third_win = open_window;
66 cmd "focus output down";
67 is($x->input_focus, $third_win->id, 'right window still focused');
69 cmd "focus output up";
70 is($x->input_focus, $third_win->id, 'right window still focused');
74 exit_gracefully($pid);
77 # Screen setup looks like this:
86 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
88 fake-outputs 1080x1920+0+0,1920x1080+1080+500
91 test_focus_left_right($config);
93 # Screen setup looks like this:
101 # i3 config file (v4)
102 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
104 fake-outputs 1080x1920+0+0,1920x200+1080+0
107 test_focus_left_right($config);
109 # Screen setup looks like this:
117 # i3 config file (v4)
118 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
120 fake-outputs 1080x1920+0+0,1920x200+1080+1720
123 test_focus_left_right($config);
125 # Screen setup looks like this:
128 # | S1 |--------+ S3 |
130 # +----+--------+----+
133 # i3 config file (v4)
134 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
136 fake-outputs 1080x1920+0+0,1920x200+1080+1720,1080x1920+1280+0
139 my $pid = launch_with_config($config);
141 my $i3 = i3(get_socket_path(0));
143 $x->root->warp_pointer(0, 0);
146 ############################################################################
147 # Ensure that focusing right/left works in the expected order.
148 ############################################################################
150 sub get_focused_output {
151 my $tree = i3(get_socket_path())->get_tree->recv;
152 my ($focused_id) = @{$tree->{focus}};
153 my ($output) = grep { $_->{id} == $focused_id } @{$tree->{nodes}};
154 return $output->{name};
157 is(get_focused_output(), 'fake-0', 'focus on fake-0');
159 cmd 'focus output right';
160 is(get_focused_output(), 'fake-1', 'focus on fake-1');
162 cmd 'focus output right';
163 is(get_focused_output(), 'fake-2', 'focus on fake-2');
165 cmd 'focus output left';
166 is(get_focused_output(), 'fake-1', 'focus on fake-1');
168 cmd 'focus output left';
169 is(get_focused_output(), 'fake-0', 'focus on fake-0');
171 cmd 'focus output left';
172 is(get_focused_output(), 'fake-2', 'focus on fake-2 (wrapping)');
174 cmd 'focus output right';
175 is(get_focused_output(), 'fake-0', 'focus on fake-0 (wrapping)');
177 exit_gracefully($pid);