]> git.sur5r.net Git - i3/i3/blob - testcases/t/102-dock.t
Merge branch 'next' into master
[i3/i3] / testcases / t / 102-dock.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3 #
4 # Please read the following documents before working on tests:
5 # • https://build.i3wm.org/docs/testsuite.html
6 #   (or docs/testsuite)
7 #
8 # • https://build.i3wm.org/docs/lib-i3test.html
9 #   (alternatively: perldoc ./testcases/lib/i3test.pm)
10 #
11 # • https://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 use i3test;
18 use X11::XCB 'PROP_MODE_REPLACE';
19 use List::Util qw(first);
20
21 #####################################################################
22 # verify that there is no dock window yet
23 #####################################################################
24
25 # Children of all dockareas
26 my @docked = get_dock_clients;
27 is(@docked, 0, 'no dock clients yet');
28
29 #####################################################################
30 # Create a dock window and see if it gets managed
31 #####################################################################
32
33 my $screens = $x->screens;
34
35 # Get the primary screen
36 my $primary = first { $_->primary } @{$screens};
37
38 # TODO: focus the primary screen before
39 my $window = open_window({
40         window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'),
41     });
42
43 my $rect = $window->rect;
44 is($rect->width, $primary->rect->width, 'dock client is as wide as the screen');
45 is($rect->height, 30, 'height is unchanged');
46
47 #####################################################################
48 # check that we can find it in the layout tree at the expected position
49 #####################################################################
50
51 @docked = get_dock_clients('top');
52 is(@docked, 1, 'one dock client found');
53
54 # verify the position/size
55 my $docknode = $docked[0];
56
57 is($docknode->{rect}->{x}, 0, 'dock node placed at x=0');
58 is($docknode->{rect}->{y}, 0, 'dock node placed at y=0');
59 is($docknode->{rect}->{width}, $primary->rect->width, 'dock node as wide as the screen');
60 is($docknode->{rect}->{height}, 30, 'dock node has unchanged height');
61
62 #####################################################################
63 # check that re-configuring the height works
64 #####################################################################
65
66 $window->rect(X11::XCB::Rect->new(x => 0, y => 0, width => 50, height => 40));
67
68 sync_with_i3;
69
70 @docked = get_dock_clients('top');
71 is(@docked, 1, 'one dock client found');
72
73 # verify the position/size
74 $docknode = $docked[0];
75
76 is($docknode->{rect}->{x}, 0, 'dock node placed at x=0');
77 is($docknode->{rect}->{y}, 0, 'dock node placed at y=0');
78 is($docknode->{rect}->{width}, $primary->rect->width, 'dock node as wide as the screen');
79 is($docknode->{rect}->{height}, 40, 'dock height changed');
80
81 $window->destroy;
82
83 wait_for_unmap $window;
84
85 @docked = get_dock_clients();
86 is(@docked, 0, 'no more dock clients');
87
88 #####################################################################
89 # check if it gets placed on bottom (by coordinates)
90 #####################################################################
91
92 $window = open_window({
93         rect => [ 0, 1000, 30, 30 ],
94         background_color => '#FF0000',
95         window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'),
96     });
97
98 $rect = $window->rect;
99 is($rect->width, $primary->rect->width, 'dock client is as wide as the screen');
100 is($rect->height, 30, 'height is unchanged');
101
102 @docked = get_dock_clients('bottom');
103 is(@docked, 1, 'dock client on bottom');
104
105 $window->destroy;
106
107 wait_for_unmap $window;
108
109 @docked = get_dock_clients();
110 is(@docked, 0, 'no more dock clients');
111
112 #####################################################################
113 # check if it gets placed on bottom (by hint)
114 #####################################################################
115
116 $window = open_window({
117         dont_map => 1,
118         rect => [ 0, 1000, 30, 30 ],
119         background_color => '#FF0000',
120         window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'),
121     });
122
123 $window->_create();
124
125 # Add a _NET_WM_STRUT_PARTIAL hint
126 my $atomname = $x->atom(name => '_NET_WM_STRUT_PARTIAL');
127 my $atomtype = $x->atom(name => 'CARDINAL');
128
129 $x->change_property(
130     PROP_MODE_REPLACE,
131     $window->id,
132     $atomname->id,
133     $atomtype->id,
134     32,         # 32 bit integer
135     12,
136     pack('L12', 0, 0, 16, 0, 0, 0, 0, 0, 0, 1280, 0, 0)
137 );
138
139 $window->map;
140
141 wait_for_map $window;
142
143 @docked = get_dock_clients('top');
144 is(@docked, 1, 'dock client on top');
145
146 # now change strut_partial to reserve space on the bottom and the dock should
147 # be moved to the bottom dock area
148 $x->change_property(
149     PROP_MODE_REPLACE,
150     $window->id,
151     $atomname->id,
152     $atomtype->id,
153     32,         # 32 bit integer
154     12,
155     pack('L12', 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 1280, 0)
156 );
157
158 sync_with_i3;
159 @docked = get_dock_clients('bottom');
160 is(@docked, 1, 'dock client on bottom');
161
162 $window->destroy;
163
164 wait_for_unmap $window;
165
166 @docked = get_dock_clients();
167 is(@docked, 0, 'no more dock clients');
168
169 $window = open_window({
170         dont_map => 1,
171         rect => [ 0, 1000, 30, 30 ],
172         background_color => '#FF0000',
173         window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'),
174     });
175
176 $window->_create();
177
178 # Add a _NET_WM_STRUT_PARTIAL hint
179 $atomname = $x->atom(name => '_NET_WM_STRUT_PARTIAL');
180 $atomtype = $x->atom(name => 'CARDINAL');
181
182 $x->change_property(
183     PROP_MODE_REPLACE,
184     $window->id,
185     $atomname->id,
186     $atomtype->id,
187     32,         # 32 bit integer
188     12,
189     pack('L12', 0, 0, 0, 16, 0, 0, 0, 0, 0, 1280, 0, 0)
190 );
191
192 $window->map;
193
194 wait_for_map $window;
195
196 @docked = get_dock_clients('bottom');
197 is(@docked, 1, 'dock client on bottom');
198
199 $window->destroy;
200
201
202 #####################################################################
203 # regression test: transient dock client
204 #####################################################################
205
206 my $fwindow = open_window({
207         dont_map => 1,
208         background_color => '#FF0000',
209         window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'),
210     });
211
212 $fwindow->transient_for($window);
213 $fwindow->map;
214
215 wait_for_map $fwindow;
216
217 does_i3_live;
218
219 done_testing;