2 # vim:ts=4:sw=4:expandtab
6 my $tmp = fresh_workspace;
8 #############################################################################
9 # 1: see if focus stays the same when toggling tiling/floating mode
10 #############################################################################
12 my $first = open_window;
13 my $second = open_window;
15 is($x->input_focus, $second->id, 'second window focused');
17 cmd 'floating enable';
18 cmd 'floating disable';
20 is($x->input_focus, $second->id, 'second window still focused after mode toggle');
22 #############################################################################
23 # 2: see if focus stays on the current floating window if killing another
25 #############################################################################
27 $tmp = fresh_workspace;
29 $first = open_window; # window 2
30 $second = open_window; # window 3
31 my $third = open_window; # window 4
33 is($x->input_focus, $third->id, 'last container focused');
35 cmd 'floating enable';
37 cmd '[id="' . $second->id . '"] focus';
41 is($x->input_focus, $second->id, 'second con focused');
43 cmd 'floating enable';
45 # now kill the third one (it's floating). focus should stay unchanged
46 cmd '[id="' . $third->id . '"] kill';
48 wait_for_unmap($third);
50 is($x->input_focus, $second->id, 'second con still focused after killing third');
53 #############################################################################
54 # 3: see if the focus gets reverted correctly when closing floating clients
55 # (first to the next floating client, then to the last focused tiling client)
56 #############################################################################
58 $tmp = fresh_workspace;
60 $first = open_window({ background_color => '#ff0000' }); # window 5
61 $second = open_window({ background_color => '#00ff00' }); # window 6
62 $third = open_window({ background_color => '#0000ff' }); # window 7
64 is($x->input_focus, $third->id, 'last container focused');
66 cmd 'floating enable';
68 cmd '[id="' . $second->id . '"] focus';
72 is($x->input_focus, $second->id, 'second con focused');
74 cmd 'floating enable';
76 # now kill the second one. focus should fall back to the third one, which is
79 wait_for_unmap($second);
81 is($x->input_focus, $third->id, 'third con focused');
84 wait_for_unmap($third);
86 is($x->input_focus, $first->id, 'first con focused after killing all floating cons');
88 #############################################################################
89 # 4: same test as 3, but with another split con
90 #############################################################################
92 $tmp = fresh_workspace;
94 $first = open_window({ background_color => '#ff0000' }); # window 5
97 $second = open_window({ background_color => '#00ff00' }); # window 6
98 $third = open_window({ background_color => '#0000ff' }); # window 7
100 is($x->input_focus, $third->id, 'last container focused');
102 cmd 'floating enable';
104 cmd '[id="' . $second->id . '"] focus';
108 is($x->input_focus, $second->id, 'second con focused');
110 cmd 'floating enable';
114 # now kill the second one. focus should fall back to the third one, which is
117 wait_for_unmap($second);
119 is($x->input_focus, $third->id, 'third con focused');
122 wait_for_unmap($third);
124 is($x->input_focus, $first->id, 'first con focused after killing all floating cons');
126 #############################################################################
127 # 5: see if the 'focus tiling' and 'focus floating' commands work
128 #############################################################################
130 $tmp = fresh_workspace;
132 $first = open_window({ background_color => '#ff0000' }); # window 8
133 $second = open_window({ background_color => '#00ff00' }); # window 9
137 is($x->input_focus, $second->id, 'second container focused');
139 cmd 'floating enable';
141 is($x->input_focus, $second->id, 'second container focused');
147 is($x->input_focus, $first->id, 'first (tiling) container focused');
149 cmd 'focus floating';
153 is($x->input_focus, $second->id, 'second (floating) container focused');
155 cmd 'focus floating';
159 is($x->input_focus, $second->id, 'second (floating) container still focused');
161 cmd 'focus mode_toggle';
165 is($x->input_focus, $first->id, 'first (tiling) container focused');
167 cmd 'focus mode_toggle';
171 is($x->input_focus, $second->id, 'second (floating) container focused');
173 #############################################################################
174 # 6: see if switching floating focus using the focus left/right command works
175 #############################################################################
177 $tmp = fresh_workspace;
179 $first = open_floating_window($x, { background_color => '#ff0000' });# window 10
180 $second = open_floating_window($x, { background_color => '#00ff00' }); # window 11
181 $third = open_floating_window($x, { background_color => '#0000ff' }); # window 12
185 is($x->input_focus, $third->id, 'third container focused');
191 is($x->input_focus, $second->id, 'second container focused');
197 is($x->input_focus, $first->id, 'first container focused');
203 is($x->input_focus, $third->id, 'focus wrapped to third container');
209 is($x->input_focus, $first->id, 'focus wrapped to first container');
215 is($x->input_focus, $second->id, 'focus on second container');