2 # vim:ts=4:sw=4:expandtab
6 use X11::XCB::Connection;
8 my $x = X11::XCB::Connection->new;
10 my $tmp = fresh_workspace;
12 #############################################################################
13 # 1: see if focus stays the same when toggling tiling/floating mode
14 #############################################################################
16 my $first = open_window($x);
17 my $second = open_window($x);
19 is($x->input_focus, $second->id, 'second window focused');
21 cmd 'floating enable';
22 cmd 'floating disable';
24 is($x->input_focus, $second->id, 'second window still focused after mode toggle');
26 #############################################################################
27 # 2: see if focus stays on the current floating window if killing another
29 #############################################################################
31 $tmp = fresh_workspace;
33 $first = open_window($x); # window 2
34 $second = open_window($x); # window 3
35 my $third = open_window($x); # window 4
37 is($x->input_focus, $third->id, 'last container focused');
39 cmd 'floating enable';
41 cmd '[id="' . $second->id . '"] focus';
45 is($x->input_focus, $second->id, 'second con focused');
47 cmd 'floating enable';
49 # now kill the third one (it's floating). focus should stay unchanged
50 cmd '[id="' . $third->id . '"] kill';
54 is($x->input_focus, $second->id, 'second con still focused after killing third');
57 #############################################################################
58 # 3: see if the focus gets reverted correctly when closing floating clients
59 # (first to the next floating client, then to the last focused tiling client)
60 #############################################################################
62 $tmp = fresh_workspace;
64 $first = open_window($x, { background_color => '#ff0000' }); # window 5
65 $second = open_window($x, { background_color => '#00ff00' }); # window 6
66 my $third = open_window($x, { background_color => '#0000ff' }); # window 7
68 is($x->input_focus, $third->id, 'last container focused');
70 cmd 'floating enable';
72 cmd '[id="' . $second->id . '"] focus';
76 is($x->input_focus, $second->id, 'second con focused');
78 cmd 'floating enable';
80 # now kill the second one. focus should fall back to the third one, which is
85 is($x->input_focus, $third->id, 'third con focused');
90 is($x->input_focus, $first->id, 'first con focused after killing all floating cons');
92 #############################################################################
93 # 4: same test as 3, but with another split con
94 #############################################################################
96 $tmp = fresh_workspace;
98 $first = open_window($x, { background_color => '#ff0000' }); # window 5
100 cmd 'layout stacked';
101 $second = open_window($x, { background_color => '#00ff00' }); # window 6
102 $third = open_window($x, { background_color => '#0000ff' }); # window 7
104 is($x->input_focus, $third->id, 'last container focused');
106 cmd 'floating enable';
108 cmd '[id="' . $second->id . '"] focus';
112 is($x->input_focus, $second->id, 'second con focused');
114 cmd 'floating enable';
118 # now kill the second one. focus should fall back to the third one, which is
123 is($x->input_focus, $third->id, 'third con focused');
128 is($x->input_focus, $first->id, 'first con focused after killing all floating cons');
130 #############################################################################
131 # 5: see if the 'focus tiling' and 'focus floating' commands work
132 #############################################################################
134 $tmp = fresh_workspace;
136 $first = open_window($x, { background_color => '#ff0000' }); # window 8
137 $second = open_window($x, { background_color => '#00ff00' }); # window 9
141 is($x->input_focus, $second->id, 'second container focused');
143 cmd 'floating enable';
145 is($x->input_focus, $second->id, 'second container focused');
151 is($x->input_focus, $first->id, 'first (tiling) container focused');
153 cmd 'focus floating';
157 is($x->input_focus, $second->id, 'second (floating) container focused');
159 cmd 'focus floating';
163 is($x->input_focus, $second->id, 'second (floating) container still focused');
165 cmd 'focus mode_toggle';
169 is($x->input_focus, $first->id, 'first (tiling) container focused');
171 cmd 'focus mode_toggle';
175 is($x->input_focus, $second->id, 'second (floating) container focused');
177 #############################################################################
178 # 6: see if switching floating focus using the focus left/right command works
179 #############################################################################
181 $tmp = fresh_workspace;
183 $first = open_floating_window($x, { background_color => '#ff0000' });# window 10
184 $second = open_floating_window($x, { background_color => '#00ff00' }); # window 11
185 $third = open_floating_window($x, { background_color => '#0000ff' }); # window 12
189 is($x->input_focus, $third->id, 'third container focused');
195 is($x->input_focus, $second->id, 'second container focused');
201 is($x->input_focus, $first->id, 'first container focused');
207 is($x->input_focus, $third->id, 'focus wrapped to third container');
213 is($x->input_focus, $first->id, 'focus wrapped to first container');
219 is($x->input_focus, $second->id, 'focus on second container');