]> git.sur5r.net Git - i3/i3/blob - testcases/t/156-fullscreen-focus.t
3a27c9ffa28ea36d50dd35f4f467937f0e6143c6
[i3/i3] / testcases / t / 156-fullscreen-focus.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3 #
4 # Test if new containers get focused when there is a fullscreen container at
5 # the time of launching the new one. Also make sure that focusing containers
6 # in other workspaces work even when there is a fullscreen container.
7 #
8 use i3test;
9
10 my $i3 = i3(get_socket_path());
11
12 my $tmp = fresh_workspace;
13
14 ################################################################################
15 # Open the left window.
16 ################################################################################
17
18 my $left = open_window({ background_color => '#ff0000' });
19
20 is($x->input_focus, $left->id, 'left window focused');
21
22 diag("left = " . $left->id);
23
24 ################################################################################
25 # Open the right window.
26 ################################################################################
27
28 my $right = open_window({ background_color => '#00ff00' });
29
30 diag("right = " . $right->id);
31
32 ################################################################################
33 # Set the right window to fullscreen.
34 ################################################################################
35
36 cmd 'nop setting fullscreen';
37 cmd 'fullscreen';
38
39 ################################################################################
40 # Open a third window. Since we're fullscreen, the window won't be # mapped, so
41 # don't wait for it to be mapped. Instead, just send the map request and sync
42 # with i3 to make sure i3 recognizes it.
43 ################################################################################
44
45 my $third = open_window({
46         background_color => '#0000ff',
47         name => 'Third window',
48         dont_map => 1,
49     });
50
51 $third->map;
52
53 sync_with_i3;
54
55 diag("third = " . $third->id);
56
57 ################################################################################
58 # Move the window to a different workspace, and verify that the third window now
59 # gets focused in the current workspace.
60 ################################################################################
61
62 my $tmp2 = get_unused_workspace;
63
64 cmd "move workspace $tmp2";
65
66 is($x->input_focus, $third->id, 'third window focused');
67
68 ################################################################################
69 # Ensure that moving a window to a workspace which has a fullscreen window does
70 # not focus it (otherwise the user cannot get out of fullscreen mode anymore).
71 ################################################################################
72
73 $tmp = fresh_workspace;
74
75 my $fullscreen_window = open_window;
76 cmd 'fullscreen';
77
78 my $nodes = get_ws_content($tmp);
79 is(scalar @$nodes, 1, 'precisely one window');
80 is($nodes->[0]->{focused}, 1, 'fullscreen window focused');
81 my $old_id = $nodes->[0]->{id};
82
83 $tmp2 = fresh_workspace;
84 my $move_window = open_window;
85 cmd "move workspace $tmp";
86
87 cmd "workspace $tmp";
88
89 $nodes = get_ws_content($tmp);
90 is(scalar @$nodes, 2, 'precisely two windows');
91 is($nodes->[0]->{id}, $old_id, 'id unchanged');
92 is($nodes->[0]->{focused}, 1, 'fullscreen window focused');
93
94 ################################################################################
95 # Ensure it's possible to change focus if it doesn't escape the fullscreen
96 # container with fullscreen global. We can't even focus a container in a
97 # different workspace.
98 ################################################################################
99
100 cmd 'fullscreen';
101
102 $tmp = fresh_workspace;
103 cmd "workspace $tmp";
104 my $diff_ws = open_window;
105
106 $tmp2 = fresh_workspace;
107 cmd "workspace $tmp2";
108 cmd 'split h';
109
110 $left = open_window;
111 my $right1 = open_window;
112 cmd 'split v';
113 my $right2 = open_window;
114 $nodes = get_ws_content($tmp);
115
116 cmd 'focus parent';
117 cmd 'fullscreen global';
118
119 cmd '[id="' . $right1->id . '"] focus';
120 is($x->input_focus, $right1->id, 'upper right window focused');
121
122 cmd '[id="' . $right2->id . '"] focus';
123 is($x->input_focus, $right2->id, 'bottom right window focused');
124
125 cmd '[id="' . $left->id . '"] focus';
126 is($x->input_focus, $right2->id, 'prevented focus change to left window');
127
128 cmd '[id="' . $diff_ws->id . '"] focus';
129 is($x->input_focus, $right2->id, 'prevented focus change to different ws');
130
131 ################################################################################
132 # Same tests when we're in non-global fullscreen mode. We toggle fullscreen on
133 # and off to avoid testing whether focus level works in fullscreen for now. It
134 # should now be possible to focus a container in a different workspace.
135 ################################################################################
136
137 cmd 'fullscreen global';
138 cmd 'fullscreen global';
139
140 cmd '[id="' . $right1->id . '"] focus';
141 is($x->input_focus, $right1->id, 'upper right window focused');
142
143 cmd 'focus parent';
144 cmd 'fullscreen';
145
146 cmd '[id="' . $right1->id . '"] focus';
147 is($x->input_focus, $right1->id, 'upper right window still focused');
148
149 cmd '[id="' . $right2->id . '"] focus';
150 is($x->input_focus, $right2->id, 'bottom right window focused');
151
152 cmd '[id="' . $left->id . '"] focus';
153 is($x->input_focus, $right2->id, 'prevented focus change to left window');
154
155 cmd '[id="' . $diff_ws->id . '"] focus';
156 is($x->input_focus, $diff_ws->id, 'allowed focus change to different ws');
157
158 done_testing;