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';
39 is($x->input_focus, $second->id, 'second con focused');
41 cmd 'floating enable';
43 # now kill the third one (it's floating). focus should stay unchanged
44 cmd '[id="' . $third->id . '"] kill';
46 wait_for_unmap($third);
48 is($x->input_focus, $second->id, 'second con still focused after killing third');
51 #############################################################################
52 # 3: see if the focus gets reverted correctly when closing floating clients
53 # (first to the next floating client, then to the last focused tiling client)
54 #############################################################################
56 $tmp = fresh_workspace;
58 $first = open_window({ background_color => '#ff0000' }); # window 5
59 $second = open_window({ background_color => '#00ff00' }); # window 6
60 $third = open_window({ background_color => '#0000ff' }); # window 7
62 is($x->input_focus, $third->id, 'last container focused');
64 cmd 'floating enable';
66 cmd '[id="' . $second->id . '"] focus';
68 is($x->input_focus, $second->id, 'second con focused');
70 cmd 'floating enable';
72 # now kill the second one. focus should fall back to the third one, which is
75 wait_for_unmap($second);
77 is($x->input_focus, $third->id, 'third con focused');
80 wait_for_unmap($third);
82 is($x->input_focus, $first->id, 'first con focused after killing all floating cons');
84 #############################################################################
85 # 4: same test as 3, but with another split con
86 #############################################################################
88 $tmp = fresh_workspace;
90 $first = open_window({ background_color => '#ff0000' }); # window 5
93 $second = open_window({ background_color => '#00ff00' }); # window 6
94 $third = open_window({ background_color => '#0000ff' }); # window 7
96 is($x->input_focus, $third->id, 'last container focused');
98 cmd 'floating enable';
100 cmd '[id="' . $second->id . '"] focus';
102 is($x->input_focus, $second->id, 'second con focused');
104 cmd 'floating enable';
108 # now kill the second one. focus should fall back to the third one, which is
111 wait_for_unmap($second);
113 is($x->input_focus, $third->id, 'third con focused');
116 wait_for_unmap($third);
118 is($x->input_focus, $first->id, 'first con focused after killing all floating cons');
120 #############################################################################
121 # 5: see if the 'focus tiling' and 'focus floating' commands work
122 #############################################################################
124 $tmp = fresh_workspace;
126 $first = open_window({ background_color => '#ff0000' }); # window 8
127 $second = open_window({ background_color => '#00ff00' }); # window 9
129 is($x->input_focus, $second->id, 'second container focused');
131 cmd 'floating enable';
133 is($x->input_focus, $second->id, 'second container focused');
137 is($x->input_focus, $first->id, 'first (tiling) container focused');
139 cmd 'focus floating';
141 is($x->input_focus, $second->id, 'second (floating) container focused');
143 cmd 'focus floating';
145 is($x->input_focus, $second->id, 'second (floating) container still focused');
147 cmd 'focus mode_toggle';
149 is($x->input_focus, $first->id, 'first (tiling) container focused');
151 cmd 'focus mode_toggle';
153 is($x->input_focus, $second->id, 'second (floating) container focused');
155 #############################################################################
156 # 6: see if switching floating focus using the focus left/right command works
157 #############################################################################
159 $tmp = fresh_workspace;
161 $first = open_floating_window({ background_color => '#ff0000' });# window 10
162 $second = open_floating_window({ background_color => '#00ff00' }); # window 11
163 $third = open_floating_window({ background_color => '#0000ff' }); # window 12
165 is($x->input_focus, $third->id, 'third container focused');
169 is($x->input_focus, $second->id, 'second container focused');
173 is($x->input_focus, $first->id, 'first container focused');
177 is($x->input_focus, $third->id, 'focus wrapped to third container');
181 is($x->input_focus, $first->id, 'focus wrapped to first container');
185 is($x->input_focus, $second->id, 'focus on second container');