]> git.sur5r.net Git - i3/i3/blob - testcases/t/510-focus-across-outputs.t
Merge branch 'fix-resize'
[i3/i3] / testcases / t / 510-focus-across-outputs.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3 #
4 # Please read the following documents before working on tests:
5 # • http://build.i3wm.org/docs/testsuite.html
6 #   (or docs/testsuite)
7 #
8 # • http://build.i3wm.org/docs/lib-i3test.html
9 #   (alternatively: perldoc ./testcases/lib/i3test.pm)
10 #
11 # • http://build.i3wm.org/docs/ipc.html
12 #   (or docs/ipc)
13 #
14 # • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
15 #   (unless you are already familiar with Perl)
16 #
17 # Tests that switching workspaces via 'focus $dir' never leaves a floating
18 # window focused.
19 #
20 use i3test i3_autostart => 0;
21
22 # Ensure the pointer is at (0, 0) so that we really start on the first
23 # (the left) workspace.
24 $x->root->warp_pointer(0, 0);
25
26 my $config = <<EOT;
27 # i3 config file (v4)
28 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
29
30 fake-outputs 1024x768+0+0,1024x768+1024+0,1024x768+0+768,1024x768+1024+768
31 EOT
32 my $pid = launch_with_config($config);
33
34 my $s0_ws = fresh_workspace;
35 my $first = open_window;
36 my $second = open_window;
37 my $third = open_window;
38 cmd 'floating toggle';
39
40 # Focus screen 1
41 $x->root->warp_pointer(1025, 0);
42 sync_with_i3;
43 my $s1_ws = fresh_workspace;
44
45 my $fourth = open_window;
46
47 # Focus screen 2
48 $x->root->warp_pointer(0, 769);
49 sync_with_i3;
50 my $s2_ws = fresh_workspace;
51
52 my $fifth = open_window;
53
54 # Focus screen 3
55 $x->root->warp_pointer(1025, 769);
56 sync_with_i3;
57 my $s3_ws = fresh_workspace;
58
59 my $sixth = open_window;
60 my $seventh = open_window;
61 my $eighth = open_window;
62 cmd 'floating toggle';
63
64 # Layout should look like this (windows 3 and 8 are floating):
65 #     S0      S1
66 # ┌───┬───┬───────┐
67 # │ ┌─┴─┐ │       │
68 # │1│ 3 │2│   4   │
69 # │ └─┬─┘ │       │
70 # ├───┴───┼───┬───┤
71 # │       │ ┌─┴─┐ │
72 # │   5   │6│ 8 │7│
73 # │       │ └─┬─┘ │
74 # └───────┴───┴───┘
75 #    S2       S3
76 #
77 ###################################################################
78 # Test that focus (left|down|right|up) doesn't focus floating
79 # windows when moving into horizontally-split workspaces.
80 ###################################################################
81
82 sub reset_focus {
83     my $ws = shift;
84     cmd "workspace $ws; focus floating";
85 }
86
87 cmd "workspace $s1_ws";
88 cmd 'focus left';
89 is($x->input_focus, $second->id, 'second window focused');
90 reset_focus $s0_ws;
91
92 cmd "workspace $s1_ws";
93 cmd 'focus down';
94 is($x->input_focus, $seventh->id, 'seventh window focused');
95 reset_focus $s3_ws;
96
97 cmd "workspace $s2_ws";
98 cmd 'focus right';
99 is($x->input_focus, $sixth->id, 'sixth window focused');
100 reset_focus $s3_ws;
101
102 cmd "workspace $s2_ws";
103 cmd 'focus up';
104 is($x->input_focus, $second->id, 'second window focused');
105 reset_focus $s0_ws;
106
107 ###################################################################
108 # Put the workspaces on screens 0 and 3 into vertical split mode
109 # and test focus (left|down|right|up) again.
110 ###################################################################
111
112 cmd "workspace $s0_ws";
113 is($x->input_focus, $third->id, 'third window focused');
114 cmd 'focus parent';
115 cmd 'focus parent';
116 cmd 'split v';
117 reset_focus $s0_ws;
118
119 cmd "workspace $s3_ws";
120 is($x->input_focus, $eighth->id, 'eighth window focused');
121 cmd 'focus parent';
122 cmd 'focus parent';
123 cmd 'split v';
124 reset_focus $s3_ws;
125
126 cmd "workspace $s1_ws";
127 cmd 'focus left';
128 is($x->input_focus, $second->id, 'second window focused');
129 reset_focus $s0_ws;
130
131 cmd "workspace $s1_ws";
132 cmd 'focus down';
133 is($x->input_focus, $sixth->id, 'sixth window focused');
134 reset_focus $s3_ws;
135
136 cmd "workspace $s2_ws";
137 cmd 'focus right';
138 is($x->input_focus, $sixth->id, 'sixth window focused');
139
140 cmd "workspace $s2_ws";
141 cmd 'focus up';
142 is($x->input_focus, $second->id, 'second window focused');
143
144 exit_gracefully($pid);
145
146 done_testing;