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_standard_window($x);
17 my $second = open_standard_window($x);
21 is($x->input_focus, $second->id, 'second window focused');
23 cmd 'floating enable';
24 cmd 'floating disable';
26 is($x->input_focus, $second->id, 'second window still focused after mode toggle');
28 #############################################################################
29 # 2: see if focus stays on the current floating window if killing another
31 #############################################################################
33 $tmp = fresh_workspace;
35 $first = open_standard_window($x); # window 2
36 $second = open_standard_window($x); # window 3
37 my $third = open_standard_window($x); # window 4
41 is($x->input_focus, $third->id, 'last container focused');
43 cmd 'floating enable';
45 cmd '[id="' . $second->id . '"] focus';
49 is($x->input_focus, $second->id, 'second con focused');
51 cmd 'floating enable';
53 # now kill the third one (it's floating). focus should stay unchanged
54 cmd '[id="' . $third->id . '"] kill';
56 # TODO: wait for unmapnotify
59 is($x->input_focus, $second->id, 'second con still focused after killing third');
62 #############################################################################
63 # 3: see if the focus gets reverted correctly when closing floating clients
64 # (first to the next floating client, then to the last focused tiling client)
65 #############################################################################
67 $tmp = fresh_workspace;
69 $first = open_standard_window($x, '#ff0000'); # window 5
70 $second = open_standard_window($x, '#00ff00'); # window 6
71 my $third = open_standard_window($x, '#0000ff'); # window 7
75 is($x->input_focus, $third->id, 'last container focused');
77 cmd 'floating enable';
79 cmd '[id="' . $second->id . '"] focus';
83 is($x->input_focus, $second->id, 'second con focused');
85 cmd 'floating enable';
87 # now kill the second one. focus should fall back to the third one, which is
91 # TODO: wait for unmapnotify
94 is($x->input_focus, $third->id, 'third con focused');
97 # TODO: wait for unmapnotify
100 is($x->input_focus, $first->id, 'first con focused after killing all floating cons');
102 #############################################################################
103 # 4: same test as 3, but with another split con
104 #############################################################################
106 $tmp = fresh_workspace;
108 $first = open_standard_window($x, '#ff0000'); # window 5
110 cmd 'layout stacked';
111 $second = open_standard_window($x, '#00ff00'); # window 6
112 $third = open_standard_window($x, '#0000ff'); # window 7
116 is($x->input_focus, $third->id, 'last container focused');
118 cmd 'floating enable';
120 cmd '[id="' . $second->id . '"] focus';
124 is($x->input_focus, $second->id, 'second con focused');
126 cmd 'floating enable';
130 # now kill the second one. focus should fall back to the third one, which is
134 # TODO: wait for unmapnotify
137 is($x->input_focus, $third->id, 'third con focused');
140 # TODO: wait for unmapnotify
143 is($x->input_focus, $first->id, 'first con focused after killing all floating cons');
145 #############################################################################
146 # 5: see if the 'focus tiling' and 'focus floating' commands work
147 #############################################################################
149 $tmp = fresh_workspace;
151 $first = open_standard_window($x, '#ff0000'); # window 8
152 $second = open_standard_window($x, '#00ff00'); # window 9
156 is($x->input_focus, $second->id, 'second container focused');
158 cmd 'floating enable';
160 is($x->input_focus, $second->id, 'second container focused');
166 is($x->input_focus, $first->id, 'first (tiling) container focused');
168 cmd 'focus floating';
172 is($x->input_focus, $second->id, 'second (floating) container focused');
174 cmd 'focus floating';
178 is($x->input_focus, $second->id, 'second (floating) container still focused');
180 cmd 'focus mode_toggle';
184 is($x->input_focus, $first->id, 'first (tiling) container focused');
186 cmd 'focus mode_toggle';
190 is($x->input_focus, $second->id, 'second (floating) container focused');
192 #############################################################################
193 # 6: see if switching floating focus using the focus left/right command works
194 #############################################################################
196 $tmp = fresh_workspace;
198 $first = open_standard_window($x, '#ff0000', 1); # window 10
199 $second = open_standard_window($x, '#00ff00', 1); # window 11
200 $third = open_standard_window($x, '#0000ff', 1); # window 12
204 is($x->input_focus, $third->id, 'third container focused');
210 is($x->input_focus, $second->id, 'second container focused');
216 is($x->input_focus, $first->id, 'first container focused');
222 is($x->input_focus, $third->id, 'focus wrapped to third container');
228 is($x->input_focus, $first->id, 'focus wrapped to first container');
234 is($x->input_focus, $second->id, 'focus on second container');