]> git.sur5r.net Git - i3/i3/blob - testcases/t/510-focus-across-outputs.t
Bump version for new CPAN upload, fix MANIFEST
[i3/i3] / testcases / t / 510-focus-across-outputs.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3 #
4 # Please read the following documents before working on tests:
5 # • http://build.i3wm.org/docs/testsuite.html
6 #   (or docs/testsuite)
7 #
8 # • http://build.i3wm.org/docs/lib-i3test.html
9 #   (alternatively: perldoc ./testcases/lib/i3test.pm)
10 #
11 # • http://build.i3wm.org/docs/ipc.html
12 #   (or docs/ipc)
13 #
14 # • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
15 #   (unless you are already familiar with Perl)
16 #
17 # Tests that switching workspaces via 'focus $dir' never leaves a floating
18 # window focused.
19 #
20 use i3test i3_autostart => 0;
21
22 # Ensure the pointer is at (0, 0) so that we really start on the first
23 # (the left) workspace.
24 $x->root->warp_pointer(0, 0);
25
26 my $config = <<EOT;
27 # i3 config file (v4)
28 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
29
30 fake-outputs 1024x768+0+0,1024x768+1024+0,1024x768+0+768,1024x768+1024+768
31 EOT
32 my $pid = launch_with_config($config);
33
34 my $s0_ws = fresh_workspace;
35 my $first = open_window;
36 my $second = open_window;
37 my $third = open_window;
38 cmd 'floating toggle';
39
40 # Focus screen 1
41 sync_with_i3;
42 $x->root->warp_pointer(1025, 0);
43 sync_with_i3;
44 my $s1_ws = fresh_workspace;
45
46 my $fourth = open_window;
47
48 # Focus screen 2
49 sync_with_i3;
50 $x->root->warp_pointer(0, 769);
51 sync_with_i3;
52 my $s2_ws = fresh_workspace;
53
54 my $fifth = open_window;
55
56 # Focus screen 3
57 sync_with_i3;
58 $x->root->warp_pointer(1025, 769);
59 sync_with_i3;
60 my $s3_ws = fresh_workspace;
61
62 my $sixth = open_window;
63 my $seventh = open_window;
64 my $eighth = open_window;
65 cmd 'floating toggle';
66
67 # Layout should look like this (windows 3 and 8 are floating):
68 #     S0      S1
69 # ┌───┬───┬───────┐
70 # │ ┌─┴─┐ │       │
71 # │1│ 3 │2│   4   │
72 # │ └─┬─┘ │       │
73 # ├───┴───┼───┬───┤
74 # │       │ ┌─┴─┐ │
75 # │   5   │6│ 8 │7│
76 # │       │ └─┬─┘ │
77 # └───────┴───┴───┘
78 #    S2       S3
79 #
80 ###################################################################
81 # Test that focus (left|down|right|up) doesn't focus floating
82 # windows when moving into horizontally-split workspaces.
83 ###################################################################
84
85 sub reset_focus {
86     my $ws = shift;
87     cmd "workspace $ws; focus floating";
88 }
89
90 cmd "workspace $s1_ws";
91 cmd 'focus left';
92 is($x->input_focus, $second->id, 'second window focused');
93 reset_focus $s0_ws;
94
95 cmd "workspace $s1_ws";
96 cmd 'focus down';
97 is($x->input_focus, $seventh->id, 'seventh window focused');
98 reset_focus $s3_ws;
99
100 cmd "workspace $s2_ws";
101 cmd 'focus right';
102 is($x->input_focus, $sixth->id, 'sixth window focused');
103 reset_focus $s3_ws;
104
105 cmd "workspace $s2_ws";
106 cmd 'focus up';
107 is($x->input_focus, $second->id, 'second window focused');
108 reset_focus $s0_ws;
109
110 ###################################################################
111 # Put the workspaces on screens 0 and 3 into vertical split mode
112 # and test focus (left|down|right|up) again.
113 ###################################################################
114
115 cmd "workspace $s0_ws";
116 is($x->input_focus, $third->id, 'third window focused');
117 cmd 'focus parent';
118 cmd 'focus parent';
119 cmd 'split v';
120 reset_focus $s0_ws;
121
122 cmd "workspace $s3_ws";
123 is($x->input_focus, $eighth->id, 'eighth window focused');
124 cmd 'focus parent';
125 cmd 'focus parent';
126 cmd 'split v';
127 reset_focus $s3_ws;
128
129 cmd "workspace $s1_ws";
130 cmd 'focus left';
131 is($x->input_focus, $second->id, 'second window focused');
132 reset_focus $s0_ws;
133
134 cmd "workspace $s1_ws";
135 cmd 'focus down';
136 is($x->input_focus, $sixth->id, 'sixth window focused');
137 reset_focus $s3_ws;
138
139 cmd "workspace $s2_ws";
140 cmd 'focus right';
141 is($x->input_focus, $sixth->id, 'sixth window focused');
142
143 cmd "workspace $s2_ws";
144 cmd 'focus up';
145 is($x->input_focus, $second->id, 'second window focused');
146
147 exit_gracefully($pid);
148
149 done_testing;