aboutsummaryrefslogtreecommitdiff
path: root/testcases/t/502-focus-output.t
blob: c13e7e14134b0d61e267e13d7c44ce51c100bb97 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!perl
# vim:ts=4:sw=4:expandtab
#
# Please read the following documents before working on tests:
# • https://build.i3wm.org/docs/testsuite.html
#   (or docs/testsuite)
#
# • https://build.i3wm.org/docs/lib-i3test.html
#   (alternatively: perldoc ./testcases/lib/i3test.pm)
#
# • https://build.i3wm.org/docs/ipc.html
#   (or docs/ipc)
#
# • https://i3wm.org/downloads/modern_perl_a4.pdf
#   (unless you are already familiar with Perl)
#
# Verifies the 'focus output' command works properly.

use i3test i3_config => <<EOT;
# i3 config file (v4)
font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1

fake-outputs 1024x768+0+0,1024x768+1024+0
EOT
use List::Util qw(first);

my $tmp = fresh_workspace;
my $i3 = i3(get_socket_path());

################################################################################
# use 'focus output' and verify that focus gets changed appropriately
################################################################################

sync_with_i3;
$x->root->warp_pointer(0, 0);
sync_with_i3;

is(focused_output, 'fake-0', 'focus on first output');

cmd 'focus output right';
is(focused_output, 'fake-1', 'focus on second output');

# focus should wrap when we focus to the right again.
cmd 'focus output right';
is(focused_output, 'fake-0', 'focus on first output again');

cmd 'focus output left';
is(focused_output, 'fake-1', 'focus back on second output');

cmd 'focus output left';
is(focused_output, 'fake-0', 'focus on first output again');

cmd 'focus output up';
is(focused_output, 'fake-0', 'focus still on first output');

cmd 'focus output down';
is(focused_output, 'fake-0', 'focus still on first output');

cmd 'focus output fake-1';
is(focused_output, 'fake-1', 'focus on second output');

cmd 'focus output fake-0';
is(focused_output, 'fake-0', 'focus on first output');

################################################################################
# use 'focus output' and verify that i3 does not crash when the currently
# focused window is floating and is only partially mapped on an output screen
################################################################################

is(focused_output, 'fake-0', 'focus on first output');

my $floating_win = open_window;
cmd 'floating toggle';
cmd 'move to absolute position -10 -10';

cmd 'focus output right';
is(focused_output, 'fake-1', 'focus on second output');

cmd 'focus output fake-0';
is(focused_output, 'fake-0', 'focus on first output');

################################################################################
# use 'focus output' with command criteria and verify that i3 does not crash
# when they don't match any window
################################################################################

is(focused_output, 'fake-0', 'focus on first output');

cmd '[con_mark=doesnotexist] focus output right';
does_i3_live;
is(focused_output, 'fake-0', 'focus remained on first output');

################################################################################
# use 'focus output' with command criteria and verify that focus gets changed
# appropriately
################################################################################

is(focused_output, 'fake-0', 'focus on first output');

my $window = open_window;

cmd 'focus output right';
is(focused_output, 'fake-1', 'focus on second output');

cmd '[id= . ' . $window->id . '] focus output right';
is(focused_output, 'fake-1', 'focus on second output after command with criteria');

cmd 'focus output right';
is(focused_output, 'fake-0', 'focus on first output after command without criteria');

done_testing;