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);
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_standard_window($x); # window 2
34 $second = open_standard_window($x); # window 3
35 my $third = open_standard_window($x); # window 4
37 is($x->input_focus, $third->id, 'last container focused');
39 cmd 'floating enable';
41 cmd '[id="' . $second->id . '"] focus';
43 is($x->input_focus, $second->id, 'second con focused');
45 cmd 'floating enable';
47 # now kill the third one (it's floating). focus should stay unchanged
48 cmd '[id="' . $third->id . '"] kill';
52 is($x->input_focus, $second->id, 'second con still focused after killing third');
55 #############################################################################
56 # 3: see if the focus gets reverted correctly when closing floating clients
57 # (first to the next floating client, then to the last focused tiling client)
58 #############################################################################
60 $tmp = fresh_workspace;
62 $first = open_standard_window($x, '#ff0000'); # window 5
63 $second = open_standard_window($x, '#00ff00'); # window 6
64 my $third = open_standard_window($x, '#0000ff'); # window 7
66 is($x->input_focus, $third->id, 'last container focused');
68 cmd 'floating enable';
70 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
82 is($x->input_focus, $third->id, 'third con focused');
88 is($x->input_focus, $first->id, 'first con focused after killing all floating cons');
90 #############################################################################
91 # 4: same test as 3, but with another split con
92 #############################################################################
94 $tmp = fresh_workspace;
96 $first = open_standard_window($x, '#ff0000'); # window 5
99 $second = open_standard_window($x, '#00ff00'); # window 6
100 $third = open_standard_window($x, '#0000ff'); # window 7
102 is($x->input_focus, $third->id, 'last container focused');
104 cmd 'floating enable';
106 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
120 is($x->input_focus, $third->id, 'second con focused');
126 is($x->input_focus, $first->id, 'first con focused after killing all floating cons');
128 #############################################################################
129 # 5: see if the 'focus tiling' and 'focus floating' commands work
130 #############################################################################
132 $tmp = fresh_workspace;
134 $first = open_standard_window($x, '#ff0000'); # window 8
135 $second = open_standard_window($x, '#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');