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