]> git.sur5r.net Git - i3/i3/blob - testcases/t/35-floating-focus.t
Merge branch 'master' into next
[i3/i3] / testcases / t / 35-floating-focus.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3
4 use i3test;
5 use X11::XCB qw(:all);
6 use X11::XCB::Connection;
7
8 my $x = X11::XCB::Connection->new;
9
10 my $tmp = fresh_workspace;
11
12 #############################################################################
13 # 1: see if focus stays the same when toggling tiling/floating mode
14 #############################################################################
15
16 my $first = open_window($x);
17 my $second = open_window($x);
18
19 is($x->input_focus, $second->id, 'second window focused');
20
21 cmd 'floating enable';
22 cmd 'floating disable';
23
24 is($x->input_focus, $second->id, 'second window still focused after mode toggle');
25
26 #############################################################################
27 # 2: see if focus stays on the current floating window if killing another
28 # floating window
29 #############################################################################
30
31 $tmp = fresh_workspace;
32
33 $first = open_window($x);    # window 2
34 $second = open_window($x);   # window 3
35 my $third = open_window($x); # window 4
36
37 is($x->input_focus, $third->id, 'last container focused');
38
39 cmd 'floating enable';
40
41 cmd '[id="' . $second->id . '"] focus';
42
43 sync_with_i3($x);
44
45 is($x->input_focus, $second->id, 'second con focused');
46
47 cmd 'floating enable';
48
49 # now kill the third one (it's floating). focus should stay unchanged
50 cmd '[id="' . $third->id . '"] kill';
51
52 # TODO: wait for unmapnotify
53 sync_with_i3($x);
54
55 is($x->input_focus, $second->id, 'second con still focused after killing third');
56
57
58 #############################################################################
59 # 3: see if the focus gets reverted correctly when closing floating clients
60 # (first to the next floating client, then to the last focused tiling client)
61 #############################################################################
62
63 $tmp = fresh_workspace;
64
65 $first = open_window($x, '#ff0000');    # window 5
66 $second = open_window($x, '#00ff00');   # window 6
67 my $third = open_window($x, '#0000ff'); # window 7
68
69 is($x->input_focus, $third->id, 'last container focused');
70
71 cmd 'floating enable';
72
73 cmd '[id="' . $second->id . '"] focus';
74
75 sync_with_i3($x);
76
77 is($x->input_focus, $second->id, 'second con focused');
78
79 cmd 'floating enable';
80
81 # now kill the second one. focus should fall back to the third one, which is
82 # also floating
83 cmd 'kill';
84
85 # TODO: wait for unmapnotify
86 sync_with_i3($x);
87
88 is($x->input_focus, $third->id, 'third con focused');
89
90 cmd 'kill';
91 # TODO: wait for unmapnotify
92 sync_with_i3($x);
93
94 is($x->input_focus, $first->id, 'first con focused after killing all floating cons');
95
96 #############################################################################
97 # 4: same test as 3, but with another split con
98 #############################################################################
99
100 $tmp = fresh_workspace;
101
102 $first = open_window($x, { background_color => '#ff0000' });    # window 5
103 cmd 'split v';
104 cmd 'layout stacked';
105 $second = open_window($x, { background_color => '#00ff00' });   # window 6
106 $third = open_window($x, { background_color => '#0000ff' }); # window 7
107
108 is($x->input_focus, $third->id, 'last container focused');
109
110 cmd 'floating enable';
111
112 cmd '[id="' . $second->id . '"] focus';
113
114 sync_with_i3($x);
115
116 is($x->input_focus, $second->id, 'second con focused');
117
118 cmd 'floating enable';
119
120 sync_with_i3($x);
121
122 # now kill the second one. focus should fall back to the third one, which is
123 # also floating
124 cmd 'kill';
125
126 # TODO: wait for unmapnotify
127 sync_with_i3($x);
128
129 is($x->input_focus, $third->id, 'third con focused');
130
131 cmd 'kill';
132 # TODO: wait for unmapnotify
133 sync_with_i3($x);
134
135 is($x->input_focus, $first->id, 'first con focused after killing all floating cons');
136
137 #############################################################################
138 # 5: see if the 'focus tiling' and 'focus floating' commands work
139 #############################################################################
140
141 $tmp = fresh_workspace;
142
143 $first = open_window($x, { background_color => '#ff0000' });    # window 8
144 $second = open_window($x, { background_color => '#00ff00' });   # window 9
145
146 sync_with_i3($x);
147
148 is($x->input_focus, $second->id, 'second container focused');
149
150 cmd 'floating enable';
151
152 is($x->input_focus, $second->id, 'second container focused');
153
154 cmd 'focus tiling';
155
156 sync_with_i3($x);
157
158 is($x->input_focus, $first->id, 'first (tiling) container focused');
159
160 cmd 'focus floating';
161
162 sync_with_i3($x);
163
164 is($x->input_focus, $second->id, 'second (floating) container focused');
165
166 cmd 'focus floating';
167
168 sync_with_i3($x);
169
170 is($x->input_focus, $second->id, 'second (floating) container still focused');
171
172 cmd 'focus mode_toggle';
173
174 sync_with_i3($x);
175
176 is($x->input_focus, $first->id, 'first (tiling) container focused');
177
178 cmd 'focus mode_toggle';
179
180 sync_with_i3($x);
181
182 is($x->input_focus, $second->id, 'second (floating) container focused');
183
184 #############################################################################
185 # 6: see if switching floating focus using the focus left/right command works
186 #############################################################################
187
188 $tmp = fresh_workspace;
189
190 $first = open_floating_window($x, { background_color => '#ff0000' });# window 10
191 $second = open_floating_window($x, { background_color => '#00ff00' }); # window 11
192 $third = open_floating_window($x, { background_color => '#0000ff' }); # window 12
193
194 sync_with_i3($x);
195
196 is($x->input_focus, $third->id, 'third container focused');
197
198 cmd 'focus left';
199
200 sync_with_i3($x);
201
202 is($x->input_focus, $second->id, 'second container focused');
203
204 cmd 'focus left';
205
206 sync_with_i3($x);
207
208 is($x->input_focus, $first->id, 'first container focused');
209
210 cmd 'focus left';
211
212 sync_with_i3($x);
213
214 is($x->input_focus, $third->id, 'focus wrapped to third container');
215
216 cmd 'focus right';
217
218 sync_with_i3($x);
219
220 is($x->input_focus, $first->id, 'focus wrapped to first container');
221
222 cmd 'focus right';
223
224 sync_with_i3($x);
225
226 is($x->input_focus, $second->id, 'focus on second container');
227
228 done_testing;