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';
52 # TODO: wait for unmapnotify
55 is($x->input_focus, $second->id, 'second con still focused after killing third');
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 #############################################################################
63 $tmp = fresh_workspace;
65 $first = open_window($x, { background_color => '#ff0000' }); # window 5
66 $second = open_window($x, { background_color => '#00ff00' }); # window 6
67 my $third = open_window($x, { background_color => '#0000ff' }); # window 7
69 is($x->input_focus, $third->id, 'last container focused');
71 cmd 'floating enable';
73 cmd '[id="' . $second->id . '"] focus';
77 is($x->input_focus, $second->id, 'second con focused');
79 cmd 'floating enable';
81 # now kill the second one. focus should fall back to the third one, which is
85 # TODO: wait for unmapnotify
88 is($x->input_focus, $third->id, 'third con focused');
91 # TODO: wait for unmapnotify
94 is($x->input_focus, $first->id, 'first con focused after killing all floating cons');
96 #############################################################################
97 # 4: same test as 3, but with another split con
98 #############################################################################
100 $tmp = fresh_workspace;
102 $first = open_window($x, { background_color => '#ff0000' }); # window 5
104 cmd 'layout stacked';
105 $second = open_window($x, { background_color => '#00ff00' }); # window 6
106 $third = open_window($x, { background_color => '#0000ff' }); # window 7
108 is($x->input_focus, $third->id, 'last container focused');
110 cmd 'floating enable';
112 cmd '[id="' . $second->id . '"] focus';
116 is($x->input_focus, $second->id, 'second con focused');
118 cmd 'floating enable';
122 # now kill the second one. focus should fall back to the third one, which is
126 # TODO: wait for unmapnotify
129 is($x->input_focus, $third->id, 'third con focused');
132 # TODO: wait for unmapnotify
135 is($x->input_focus, $first->id, 'first con focused after killing all floating cons');
137 #############################################################################
138 # 5: see if the 'focus tiling' and 'focus floating' commands work
139 #############################################################################
141 $tmp = fresh_workspace;
143 $first = open_window($x, { background_color => '#ff0000' }); # window 8
144 $second = open_window($x, { background_color => '#00ff00' }); # window 9
148 is($x->input_focus, $second->id, 'second container focused');
150 cmd 'floating enable';
152 is($x->input_focus, $second->id, 'second container focused');
158 is($x->input_focus, $first->id, 'first (tiling) container focused');
160 cmd 'focus floating';
164 is($x->input_focus, $second->id, 'second (floating) container focused');
166 cmd 'focus floating';
170 is($x->input_focus, $second->id, 'second (floating) container still focused');
172 cmd 'focus mode_toggle';
176 is($x->input_focus, $first->id, 'first (tiling) container focused');
178 cmd 'focus mode_toggle';
182 is($x->input_focus, $second->id, 'second (floating) container focused');
184 #############################################################################
185 # 6: see if switching floating focus using the focus left/right command works
186 #############################################################################
188 $tmp = fresh_workspace;
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
196 is($x->input_focus, $third->id, 'third container focused');
202 is($x->input_focus, $second->id, 'second container focused');
208 is($x->input_focus, $first->id, 'first container focused');
214 is($x->input_focus, $third->id, 'focus wrapped to third container');
220 is($x->input_focus, $first->id, 'focus wrapped to first container');
226 is($x->input_focus, $second->id, 'focus on second container');