]> git.sur5r.net Git - i3/i3/blob - testcases/t/156-fullscreen-focus.t
add banner.svg to contrib/
[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 cmd 'nop setting fullscreen';
36 cmd 'fullscreen';
37
38 #####################################################################
39 # Open a third window
40 #####################################################################
41
42 my $third = open_window({
43         background_color => '#0000ff',
44         name => 'Third window',
45         dont_map => 1,
46     });
47
48 $third->map;
49
50 sync_with_i3;
51
52 diag("third = " . $third->id);
53
54 # move the fullscreen window to a different ws
55
56 my $tmp2 = get_unused_workspace;
57
58 cmd "move workspace $tmp2";
59
60 # verify that the third window has the focus
61 is($x->input_focus, $third->id, 'third window focused');
62
63 ################################################################################
64 # Ensure that moving a window to a workspace which has a fullscreen window does
65 # not focus it (otherwise the user cannot get out of fullscreen mode anymore).
66 ################################################################################
67
68 $tmp = fresh_workspace;
69
70 my $fullscreen_window = open_window;
71 cmd 'fullscreen';
72
73 my $nodes = get_ws_content($tmp);
74 is(scalar @$nodes, 1, 'precisely one window');
75 is($nodes->[0]->{focused}, 1, 'fullscreen window focused');
76 my $old_id = $nodes->[0]->{id};
77
78 $tmp2 = fresh_workspace;
79 my $move_window = open_window;
80 cmd "move workspace $tmp";
81
82 cmd "workspace $tmp";
83
84 $nodes = get_ws_content($tmp);
85 is(scalar @$nodes, 2, 'precisely two windows');
86 is($nodes->[0]->{id}, $old_id, 'id unchanged');
87 is($nodes->[0]->{focused}, 1, 'fullscreen window focused');
88
89 ################################################################################
90 # Make sure it's possible to focus a container in a different workspace even if
91 # we are currently focusing a fullscreen container.
92 ################################################################################
93
94 $tmp2 = fresh_workspace;
95 my $focusable_window = open_window;
96
97 cmd "workspace $tmp";
98 cmd '[id="' . $focusable_window->id . '"] focus';
99
100 is(focused_ws(), $tmp2, 'focus went to a different workspace');
101
102 $nodes = get_ws_content($tmp2);
103 is(scalar @$nodes, 1, 'precisely one window');
104 is($nodes->[0]->{focused}, 1, 'focusable window focused');
105
106 done_testing;