]> git.sur5r.net Git - i3/i3/blob - testcases/t/35-floating-focus.t
testcase: correct window names (trivial)
[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 'mode floating';
22 cmd 'mode tiling';
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 'mode floating';
40
41 cmd '[id="' . $second->id . '"] focus';
42
43 is($x->input_focus, $second->id, 'second con focused');
44
45 cmd 'mode floating';
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);    # window 5
63 $second = open_standard_window($x);   # window 6
64 my $third = open_standard_window($x); # window 7
65
66 is($x->input_focus, $third->id, 'last container focused');
67
68 cmd 'mode floating';
69
70 cmd '[id="' . $second->id . '"] focus';
71
72 is($x->input_focus, $second->id, 'second con focused');
73
74 cmd 'mode floating';
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 done_testing;