2 # vim:ts=4:sw=4:expandtab
6 use List::Util qw(first);
9 use_ok('X11::XCB::Connection') or BAIL_OUT('Cannot load X11::XCB::Connection');
12 my $x = X11::XCB::Connection->new;
14 #####################################################################
15 # verify that there is no dock window yet
16 #####################################################################
18 # Children of all dockareas
19 my @docked = get_dock_clients;
20 is(@docked, 0, 'no dock clients yet');
22 #####################################################################
23 # Create a dock window and see if it gets managed
24 #####################################################################
26 my $screens = $x->screens;
28 # Get the primary screen
29 my $primary = first { $_->primary } @{$screens};
31 # TODO: focus the primary screen before
32 my $window = open_window($x, {
33 window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'),
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');
40 #####################################################################
41 # check that we can find it in the layout tree at the expected position
42 #####################################################################
44 @docked = get_dock_clients('top');
45 is(@docked, 1, 'one dock client found');
47 # verify the position/size
48 my $docknode = $docked[0];
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');
55 #####################################################################
56 # check that re-configuring the height works
57 #####################################################################
59 $window->rect(X11::XCB::Rect->new(x => 0, y => 0, width => 50, height => 40));
63 @docked = get_dock_clients('top');
64 is(@docked, 1, 'one dock client found');
66 # verify the position/size
67 $docknode = $docked[0];
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');
78 @docked = get_dock_clients();
79 is(@docked, 0, 'no more dock clients');
81 #####################################################################
82 # check if it gets placed on bottom (by coordinates)
83 #####################################################################
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'),
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');
95 @docked = get_dock_clients('bottom');
96 is(@docked, 1, 'dock client on bottom');
102 @docked = get_dock_clients();
103 is(@docked, 0, 'no more dock clients');
105 #####################################################################
106 # check if it gets placed on bottom (by hint)
107 #####################################################################
109 $window = open_window($x, {
111 rect => [ 0, 1000, 30, 30 ],
112 background_color => '#FF0000',
113 window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'),
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');
129 pack('L12', 0, 0, 16, 0, 0, 0, 0, 0, 0, 1280, 0, 0)
136 @docked = get_dock_clients('top');
137 is(@docked, 1, 'dock client on top');
143 @docked = get_dock_clients();
144 is(@docked, 0, 'no more dock clients');
146 $window = open_window($x, {
148 rect => [ 0, 1000, 30, 30 ],
149 background_color => '#FF0000',
150 window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'),
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');
166 pack('L12', 0, 0, 0, 16, 0, 0, 0, 0, 0, 1280, 0, 0)
173 @docked = get_dock_clients('bottom');
174 is(@docked, 1, 'dock client on bottom');
179 #####################################################################
180 # regression test: transient dock client
181 #####################################################################
183 $fwindow = open_window($x, {
185 background_color => '#FF0000',
186 window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'),
189 $fwindow->transient_for($window);