2 # vim:ts=4:sw=4:expandtab
5 use X11::XCB 'PROP_MODE_REPLACE';
6 use List::Util qw(first);
8 #####################################################################
9 # verify that there is no dock window yet
10 #####################################################################
12 # Children of all dockareas
13 my @docked = get_dock_clients;
14 is(@docked, 0, 'no dock clients yet');
16 #####################################################################
17 # Create a dock window and see if it gets managed
18 #####################################################################
20 my $screens = $x->screens;
22 # Get the primary screen
23 my $primary = first { $_->primary } @{$screens};
25 # TODO: focus the primary screen before
26 my $window = open_window({
27 window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'),
30 my $rect = $window->rect;
31 is($rect->width, $primary->rect->width, 'dock client is as wide as the screen');
32 is($rect->height, 30, 'height is unchanged');
34 #####################################################################
35 # check that we can find it in the layout tree at the expected position
36 #####################################################################
38 @docked = get_dock_clients('top');
39 is(@docked, 1, 'one dock client found');
41 # verify the position/size
42 my $docknode = $docked[0];
44 is($docknode->{rect}->{x}, 0, 'dock node placed at x=0');
45 is($docknode->{rect}->{y}, 0, 'dock node placed at y=0');
46 is($docknode->{rect}->{width}, $primary->rect->width, 'dock node as wide as the screen');
47 is($docknode->{rect}->{height}, 30, 'dock node has unchanged height');
49 #####################################################################
50 # check that re-configuring the height works
51 #####################################################################
53 $window->rect(X11::XCB::Rect->new(x => 0, y => 0, width => 50, height => 40));
57 @docked = get_dock_clients('top');
58 is(@docked, 1, 'one dock client found');
60 # verify the position/size
61 $docknode = $docked[0];
63 is($docknode->{rect}->{x}, 0, 'dock node placed at x=0');
64 is($docknode->{rect}->{y}, 0, 'dock node placed at y=0');
65 is($docknode->{rect}->{width}, $primary->rect->width, 'dock node as wide as the screen');
66 is($docknode->{rect}->{height}, 40, 'dock height changed');
70 wait_for_unmap $window;
72 @docked = get_dock_clients();
73 is(@docked, 0, 'no more dock clients');
75 #####################################################################
76 # check if it gets placed on bottom (by coordinates)
77 #####################################################################
79 $window = open_window({
80 rect => [ 0, 1000, 30, 30 ],
81 background_color => '#FF0000',
82 window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'),
85 $rect = $window->rect;
86 is($rect->width, $primary->rect->width, 'dock client is as wide as the screen');
87 is($rect->height, 30, 'height is unchanged');
89 @docked = get_dock_clients('bottom');
90 is(@docked, 1, 'dock client on bottom');
94 wait_for_unmap $window;
96 @docked = get_dock_clients();
97 is(@docked, 0, 'no more dock clients');
99 #####################################################################
100 # check if it gets placed on bottom (by hint)
101 #####################################################################
103 $window = open_window({
105 rect => [ 0, 1000, 30, 30 ],
106 background_color => '#FF0000',
107 window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'),
112 # Add a _NET_WM_STRUT_PARTIAL hint
113 my $atomname = $x->atom(name => '_NET_WM_STRUT_PARTIAL');
114 my $atomtype = $x->atom(name => 'CARDINAL');
123 pack('L12', 0, 0, 16, 0, 0, 0, 0, 0, 0, 1280, 0, 0)
128 wait_for_map $window;
130 @docked = get_dock_clients('top');
131 is(@docked, 1, 'dock client on top');
135 wait_for_unmap $window;
137 @docked = get_dock_clients();
138 is(@docked, 0, 'no more dock clients');
140 $window = open_window({
142 rect => [ 0, 1000, 30, 30 ],
143 background_color => '#FF0000',
144 window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'),
149 # Add a _NET_WM_STRUT_PARTIAL hint
150 $atomname = $x->atom(name => '_NET_WM_STRUT_PARTIAL');
151 $atomtype = $x->atom(name => 'CARDINAL');
160 pack('L12', 0, 0, 0, 16, 0, 0, 0, 0, 0, 1280, 0, 0)
165 wait_for_map $window;
167 @docked = get_dock_clients('bottom');
168 is(@docked, 1, 'dock client on bottom');
173 #####################################################################
174 # regression test: transient dock client
175 #####################################################################
177 my $fwindow = open_window({
179 background_color => '#FF0000',
180 window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'),
183 $fwindow->transient_for($window);
186 wait_for_map $fwindow;