]> git.sur5r.net Git - i3/i3/blob - testcases/t/35-floating-focus.t
Merge branch 'userguide-mark'
[i3/i3] / testcases / t / 35-floating-focus.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3
4 use i3test;
5 use X11::XCB qw(:all);
6 use X11::XCB::Connection;
7
8 my $x = X11::XCB::Connection->new;
9
10 my $tmp = fresh_workspace;
11
12 #############################################################################
13 # 1: see if focus stays the same when toggling tiling/floating mode
14 #############################################################################
15
16 my $first = open_standard_window($x);
17 my $second = open_standard_window($x);
18
19 is($x->input_focus, $second->id, 'second window focused');
20
21 cmd 'floating enable';
22 cmd 'floating disable';
23
24 is($x->input_focus, $second->id, 'second window still focused after mode toggle');
25
26 #############################################################################
27 # 2: see if focus stays on the current floating window if killing another
28 # floating window
29 #############################################################################
30
31 $tmp = fresh_workspace;
32
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
36
37 is($x->input_focus, $third->id, 'last container focused');
38
39 cmd 'floating enable';
40
41 cmd '[id="' . $second->id . '"] focus';
42
43 is($x->input_focus, $second->id, 'second con focused');
44
45 cmd 'floating enable';
46
47 # now kill the third one (it's floating). focus should stay unchanged
48 cmd '[id="' . $third->id . '"] kill';
49
50 sleep 0.25;
51
52 is($x->input_focus, $second->id, 'second con still focused after killing third');
53
54
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 #############################################################################
59
60 $tmp = fresh_workspace;
61
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
65
66 is($x->input_focus, $third->id, 'last container focused');
67
68 cmd 'floating enable';
69
70 cmd '[id="' . $second->id . '"] focus';
71
72 is($x->input_focus, $second->id, 'second con focused');
73
74 cmd 'floating enable';
75
76 # now kill the second one. focus should fall back to the third one, which is
77 # also floating
78 cmd 'kill';
79
80 sleep 0.25;
81
82 is($x->input_focus, $third->id, 'third con focused');
83
84 cmd 'kill';
85
86 sleep 0.25;
87
88 is($x->input_focus, $first->id, 'first con focused after killing all floating cons');
89
90 #############################################################################
91 # 4: same test as 3, but with another split con
92 #############################################################################
93
94 $tmp = fresh_workspace;
95
96 $first = open_standard_window($x, '#ff0000');    # window 5
97 cmd 'split v';
98 cmd 'layout stacked';
99 $second = open_standard_window($x, '#00ff00');   # window 6
100 $third = open_standard_window($x, '#0000ff'); # window 7
101
102 is($x->input_focus, $third->id, 'last container focused');
103
104 cmd 'floating enable';
105
106 cmd '[id="' . $second->id . '"] focus';
107
108 is($x->input_focus, $second->id, 'second con focused');
109
110 cmd 'floating enable';
111
112 sleep 0.5;
113
114 # now kill the second one. focus should fall back to the third one, which is
115 # also floating
116 cmd 'kill';
117
118 sleep 0.25;
119
120 is($x->input_focus, $third->id, 'second con focused');
121
122 cmd 'kill';
123
124 sleep 0.25;
125
126 is($x->input_focus, $first->id, 'first con focused after killing all floating cons');
127
128 #############################################################################
129 # 5: see if the 'focus tiling' and 'focus floating' commands work
130 #############################################################################
131
132 $tmp = fresh_workspace;
133
134 $first = open_standard_window($x, '#ff0000');    # window 8
135 $second = open_standard_window($x, '#00ff00');   # window 9
136
137 is($x->input_focus, $second->id, 'second container focused');
138
139 cmd 'floating enable';
140
141 is($x->input_focus, $second->id, 'second container focused');
142
143 cmd 'focus tiling';
144
145 sleep 0.25;
146
147 is($x->input_focus, $first->id, 'first (tiling) container focused');
148
149 cmd 'focus floating';
150
151 sleep 0.25;
152
153 is($x->input_focus, $second->id, 'second (floating) container focused');
154
155 cmd 'focus floating';
156
157 sleep 0.25;
158
159 is($x->input_focus, $second->id, 'second (floating) container still focused');
160
161 cmd 'focus mode_toggle';
162
163 sleep 0.25;
164
165 is($x->input_focus, $first->id, 'first (tiling) container focused');
166
167 cmd 'focus mode_toggle';
168
169 sleep 0.25;
170
171 is($x->input_focus, $second->id, 'second (floating) container focused');
172
173
174 done_testing;