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));
32 $x->root->warp_pointer(0, 0);
35 ############################################################################
36 # Ensure that moving left and right works.
37 ############################################################################
39 # First ensure both workspaces have something to focus
41 my $left_win = open_window;
44 my $right_win = open_window;
46 is($x->input_focus, $right_win->id, 'right window focused');
48 cmd "focus output left";
49 is($x->input_focus, $left_win->id, 'left window focused');
51 cmd "focus output right";
52 is($x->input_focus, $right_win->id, 'right window focused');
54 cmd "focus output right";
55 is($x->input_focus, $left_win->id, 'left window focused (wrapping)');
57 cmd "focus output left";
58 is($x->input_focus, $right_win->id, 'right window focused (wrapping)');
60 ############################################################################
61 # Ensure that moving down/up from S0 doesn’t crash i3 and is a no-op.
62 ############################################################################
64 my $second = fresh_workspace(output => 1);
65 my $third_win = open_window;
67 cmd "focus output down";
68 is($x->input_focus, $third_win->id, 'right window still focused');
70 cmd "focus output up";
71 is($x->input_focus, $third_win->id, 'right window still focused');
75 exit_gracefully($pid);
78 # Screen setup looks like this:
87 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
89 fake-outputs 1080x1920+0+0,1920x1080+1080+500
92 test_focus_left_right($config);
94 # Screen setup looks like this:
102 # i3 config file (v4)
103 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
105 fake-outputs 1080x1920+0+0,1920x200+1080+0
108 test_focus_left_right($config);
110 # Screen setup looks like this:
118 # i3 config file (v4)
119 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
121 fake-outputs 1080x1920+0+0,1920x200+1080+1720
124 test_focus_left_right($config);
126 # Screen setup looks like this:
129 # | S1 |--------+ S3 |
131 # +----+--------+----+
134 # i3 config file (v4)
135 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
137 fake-outputs 1080x1920+0+0,1920x200+1080+1720,1080x1920+1280+0
140 my $pid = launch_with_config($config);
142 my $i3 = i3(get_socket_path(0));
145 $x->root->warp_pointer(0, 0);
148 ############################################################################
149 # Ensure that focusing right/left works in the expected order.
150 ############################################################################
152 sub get_focused_output {
153 my $tree = i3(get_socket_path())->get_tree->recv;
154 my ($focused_id) = @{$tree->{focus}};
155 my ($output) = grep { $_->{id} == $focused_id } @{$tree->{nodes}};
156 return $output->{name};
159 is(get_focused_output(), 'fake-0', 'focus on fake-0');
161 cmd 'focus output right';
162 is(get_focused_output(), 'fake-1', 'focus on fake-1');
164 cmd 'focus output right';
165 is(get_focused_output(), 'fake-2', 'focus on fake-2');
167 cmd 'focus output left';
168 is(get_focused_output(), 'fake-1', 'focus on fake-1');
170 cmd 'focus output left';
171 is(get_focused_output(), 'fake-0', 'focus on fake-0');
173 cmd 'focus output left';
174 is(get_focused_output(), 'fake-2', 'focus on fake-2 (wrapping)');
176 cmd 'focus output right';
177 is(get_focused_output(), 'fake-0', 'focus on fake-0 (wrapping)');
179 exit_gracefully($pid);