]> git.sur5r.net Git - i3/i3/blob - testcases/t/510-focus-across-outputs.t
8097f73f0fe7f1bd502a9dbce00f21d3ac8253a7
[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_config => <<EOT;
21 # i3 config file (v4)
22 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
23
24 fake-outputs 1024x768+0+0,1024x768+1024+0,1024x768+0+768,1024x768+1024+768
25 EOT
26
27 my $s0_ws = fresh_workspace;
28 my $first = open_window;
29 my $second = open_window;
30 my $third = open_window;
31 cmd 'floating toggle';
32
33 # Focus screen 1
34 sync_with_i3;
35 $x->root->warp_pointer(1025, 0);
36 sync_with_i3;
37 my $s1_ws = fresh_workspace;
38
39 my $fourth = open_window;
40
41 # Focus screen 2
42 sync_with_i3;
43 $x->root->warp_pointer(0, 769);
44 sync_with_i3;
45 my $s2_ws = fresh_workspace;
46
47 my $fifth = open_window;
48
49 # Focus screen 3
50 sync_with_i3;
51 $x->root->warp_pointer(1025, 769);
52 sync_with_i3;
53 my $s3_ws = fresh_workspace;
54
55 my $sixth = open_window;
56 my $seventh = open_window;
57 my $eighth = open_window;
58 cmd 'floating toggle';
59
60 # Layout should look like this (windows 3 and 8 are floating):
61 #     S0      S1
62 # ┌───┬───┬───────┐
63 # │ ┌─┴─┐ │       │
64 # │1│ 3 │2│   4   │
65 # │ └─┬─┘ │       │
66 # ├───┴───┼───┬───┤
67 # │       │ ┌─┴─┐ │
68 # │   5   │6│ 8 │7│
69 # │       │ └─┬─┘ │
70 # └───────┴───┴───┘
71 #    S2       S3
72 #
73 ###################################################################
74 # Test that focus (left|down|right|up) doesn't focus floating
75 # windows when moving into horizontally-split workspaces.
76 ###################################################################
77
78 sub reset_focus {
79     my $ws = shift;
80     cmd "workspace $ws; focus floating";
81 }
82
83 cmd "workspace $s1_ws";
84 cmd 'focus left';
85 is($x->input_focus, $second->id, 'second window focused');
86 reset_focus $s0_ws;
87
88 cmd "workspace $s1_ws";
89 cmd 'focus down';
90 is($x->input_focus, $seventh->id, 'seventh window focused');
91 reset_focus $s3_ws;
92
93 cmd "workspace $s2_ws";
94 cmd 'focus right';
95 is($x->input_focus, $sixth->id, 'sixth window focused');
96 reset_focus $s3_ws;
97
98 cmd "workspace $s2_ws";
99 cmd 'focus up';
100 is($x->input_focus, $second->id, 'second window focused');
101 reset_focus $s0_ws;
102
103 ###################################################################
104 # Put the workspaces on screens 0 and 3 into vertical split mode
105 # and test focus (left|down|right|up) again.
106 ###################################################################
107
108 cmd "workspace $s0_ws";
109 is($x->input_focus, $third->id, 'third window focused');
110 cmd 'focus parent';
111 cmd 'focus parent';
112 cmd 'split v';
113 reset_focus $s0_ws;
114
115 cmd "workspace $s3_ws";
116 is($x->input_focus, $eighth->id, 'eighth window focused');
117 cmd 'focus parent';
118 cmd 'focus parent';
119 cmd 'split v';
120 reset_focus $s3_ws;
121
122 cmd "workspace $s1_ws";
123 cmd 'focus left';
124 is($x->input_focus, $second->id, 'second window focused');
125 reset_focus $s0_ws;
126
127 cmd "workspace $s1_ws";
128 cmd 'focus down';
129 is($x->input_focus, $sixth->id, 'sixth window focused');
130 reset_focus $s3_ws;
131
132 cmd "workspace $s2_ws";
133 cmd 'focus right';
134 is($x->input_focus, $sixth->id, 'sixth window focused');
135
136 cmd "workspace $s2_ws";
137 cmd 'focus up';
138 is($x->input_focus, $second->id, 'second window focused');
139
140 done_testing;