aboutsummaryrefslogtreecommitdiff
path: root/testcases/t/551-net-wm-state-maximized.t
blob: b8a63b073225c1b9b13569755ab4918d69f8b0cb (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
112
113
114
115
116
117
118
119
120
121
122
123
#!perl
# vim:ts=4:sw=4:expandtab
#
# Please read the following documents before working on tests:
# • http://build.i3wm.org/docs/testsuite.html
#   (or docs/testsuite)
#
# • http://build.i3wm.org/docs/lib-i3test.html
#   (alternatively: perldoc ./testcases/lib/i3test.pm)
#
# • http://build.i3wm.org/docs/ipc.html
#   (or docs/ipc)
#
# • https://i3wm.org/downloads/modern_perl_a4.pdf
#   (unless you are already familiar with Perl)
#
# Tests for setting and removing the _NET_WM_STATE_MAXIMIZED_VERT and
# _NET_WM_STATE_MAXIMIZED_HORZ atoms.
use i3test;
use X11::XCB qw(:all);

sub maximized_vert {
    my ($window) = @_;
    return net_wm_state_contains($window, '_NET_WM_STATE_MAXIMIZED_VERT');
}

sub maximized_horz {
    my ($window) = @_;
    return net_wm_state_contains($window, '_NET_WM_STATE_MAXIMIZED_HORZ');
}

# Returns true if the given window is maximized in both directions.
sub maximized_both {
    my ($window) = @_;
    return maximized_vert($window) && maximized_horz($window);
}

# Returns true if the given window is maximized in neither direction.
sub maximized_neither {
    my ($window) = @_;
    return !maximized_vert($window) && !maximized_horz($window);
}

my ($winA, $winB, $winC);
fresh_workspace;

$winA = open_window;
ok(maximized_both($winA), 'if there is just one window, it is maximized');

cmd 'fullscreen enable';
ok(maximized_neither($winA), 'fullscreen windows are not maximized');

cmd 'fullscreen disable';
ok(maximized_both($winA), 'disabling fullscreen sets maximized to true again');

cmd 'floating enable';
ok(maximized_neither($winA), 'floating windows are not maximized');

cmd 'floating disable';
ok(maximized_both($winA), 'disabling floating sets maximized to true again');

# Open a second window.
$winB = open_window;

# Windows in stacked or tabbed containers are considered maximized.
cmd 'layout stacking';
ok(maximized_both($winA), 'stacking layout maximizes all windows');
ok(maximized_both($winB), 'stacking layout maximizes all windows');

cmd 'layout tabbed';
ok(maximized_both($winA), 'tabbed layout maximizes all windows');
ok(maximized_both($winB), 'tabbed layout maximizes all windows');

# Arrange the two windows with a vertical split.
cmd 'layout splitv';
ok(!maximized_vert($winA),
   'vertical split means children are not maximized vertically');
ok(!maximized_vert($winB),
   'vertical split means children are not maximized vertically');
ok(maximized_horz($winA),
   'children may still be maximized horizontally in a vertical split');
ok(maximized_horz($winB),
   'children may still be maximized horizontally in a vertical split');

# Arrange the two windows with a horizontal split.
cmd 'layout splith';
ok(maximized_vert($winA),
   'children may still be maximized vertically in a horizontal split');
ok(maximized_vert($winB),
   'children may still be maximized vertically in a horizontal split');
ok(!maximized_horz($winA),
   'horizontal split means children are not maximized horizontally');
ok(!maximized_horz($winB),
   'horizontal split means children are not maximized horizontally');

# Add a vertical split within the horizontal split, and open a third window.
cmd 'split vertical';
$winC = open_window;
ok(maximized_vert($winA), 'winA still reaches from top to bottom');
ok(!maximized_vert($winB),
   'winB and winC are split vertically, so they are not maximized vertically');
ok(!maximized_vert($winC),
   'winB and winC are split vertically, so they are not maximized vertically');
ok(!maximized_horz($winA),
   'horizontal split means children are not maximized horizontally');
ok(!maximized_horz($winB),
   'horizontal split means children are not maximized horizontally');
ok(!maximized_horz($winC),
   'horizontal split means children are not maximized horizontally');

# Change the vertical split container to a tabbed container.
cmd 'layout tabbed';
ok(maximized_vert($winA), 'all windows now reach from top to bottom');
ok(maximized_vert($winB), 'all windows now reach from top to bottom');
ok(maximized_vert($winC), 'all windows now reach from top to bottom');
ok(!maximized_horz($winA),
   'horizontal split means children are not maximized horizontally');
ok(!maximized_horz($winB),
   'horizontal split means children are not maximized horizontally');
ok(!maximized_horz($winC),
   'horizontal split means children are not maximized horizontally');

done_testing;