2 # vim:ts=4:sw=4:expandtab
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.
10 my $i3 = i3(get_socket_path());
12 my $tmp = fresh_workspace;
14 #####################################################################
15 # open the left window
16 #####################################################################
18 my $left = open_window({ background_color => '#ff0000' });
20 is($x->input_focus, $left->id, 'left window focused');
22 diag("left = " . $left->id);
24 #####################################################################
25 # Open the right window
26 #####################################################################
28 my $right = open_window({ background_color => '#00ff00' });
30 diag("right = " . $right->id);
32 #####################################################################
33 # Set the right window to fullscreen
34 #####################################################################
35 cmd 'nop setting fullscreen';
38 #####################################################################
40 #####################################################################
42 my $third = open_window({
43 background_color => '#0000ff',
44 name => 'Third window',
52 diag("third = " . $third->id);
54 # move the fullscreen window to a different ws
56 my $tmp2 = get_unused_workspace;
58 cmd "move workspace $tmp2";
60 # verify that the third window has the focus
61 is($x->input_focus, $third->id, 'third window focused');
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 ################################################################################
68 $tmp = fresh_workspace;
70 my $fullscreen_window = open_window;
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};
78 $tmp2 = fresh_workspace;
79 my $move_window = open_window;
80 cmd "move workspace $tmp";
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');
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 ################################################################################
94 $tmp2 = fresh_workspace;
95 my $focusable_window = open_window;
98 cmd '[id="' . $focusable_window->id . '"] focus';
100 is(focused_ws(), $tmp2, 'focus went to a different workspace');
102 $nodes = get_ws_content($tmp2);
103 is(scalar @$nodes, 1, 'precisely one window');
104 is($nodes->[0]->{focused}, 1, 'focusable window focused');