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