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
33 my $window = $x->root->create_child(
34 class => WINDOW_CLASS_INPUT_OUTPUT,
35 rect => [ 0, 0, 30, 30],
36 background_color => '#FF0000',
37 window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'),
38 event_mask => [ 'structure_notify' ],
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');
49 #####################################################################
50 # check that we can find it in the layout tree at the expected position
51 #####################################################################
53 @docked = get_dock_clients('top');
54 is(@docked, 1, 'one dock client found');
56 # verify the position/size
57 my $docknode = $docked[0];
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');
64 #####################################################################
65 # check that re-configuring the height works
66 #####################################################################
68 $window->rect(X11::XCB::Rect->new(x => 0, y => 0, width => 50, height => 40));
72 @docked = get_dock_clients('top');
73 is(@docked, 1, 'one dock client found');
75 # verify the position/size
76 $docknode = $docked[0];
78 is($docknode->{rect}->{x}, 0, 'dock node placed at x=0');
79 is($docknode->{rect}->{y}, 0, 'dock node placed at y=0');
80 is($docknode->{rect}->{width}, $primary->rect->width, 'dock node as wide as the screen');
81 is($docknode->{rect}->{height}, 40, 'dock height changed');
87 @docked = get_dock_clients();
88 is(@docked, 0, 'no more dock clients');
90 #####################################################################
91 # check if it gets placed on bottom (by coordinates)
92 #####################################################################
94 $window = $x->root->create_child(
95 class => WINDOW_CLASS_INPUT_OUTPUT,
96 rect => [ 0, 1000, 30, 30],
97 background_color => '#FF0000',
98 window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'),
99 event_mask => [ 'structure_notify' ],
106 my $rect = $window->rect;
107 is($rect->width, $primary->rect->width, 'dock client is as wide as the screen');
108 is($rect->height, 30, 'height is unchanged');
110 @docked = get_dock_clients('bottom');
111 is(@docked, 1, 'dock client on bottom');
117 @docked = get_dock_clients();
118 is(@docked, 0, 'no more dock clients');
120 #####################################################################
121 # check if it gets placed on bottom (by hint)
122 #####################################################################
124 $window = $x->root->create_child(
125 class => WINDOW_CLASS_INPUT_OUTPUT,
126 rect => [ 0, 1000, 30, 30],
127 background_color => '#FF0000',
128 window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'),
129 event_mask => [ 'structure_notify' ],
134 # Add a _NET_WM_STRUT_PARTIAL hint
135 my $atomname = $x->atom(name => '_NET_WM_STRUT_PARTIAL');
136 my $atomtype = $x->atom(name => 'CARDINAL');
145 pack('L12', 0, 0, 16, 0, 0, 0, 0, 0, 0, 1280, 0, 0)
152 @docked = get_dock_clients('top');
153 is(@docked, 1, 'dock client on top');
159 @docked = get_dock_clients();
160 is(@docked, 0, 'no more dock clients');
162 $window = $x->root->create_child(
163 class => WINDOW_CLASS_INPUT_OUTPUT,
164 rect => [ 0, 1000, 30, 30],
165 background_color => '#FF0000',
166 window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'),
167 event_mask => [ 'structure_notify' ],
172 # Add a _NET_WM_STRUT_PARTIAL hint
173 my $atomname = $x->atom(name => '_NET_WM_STRUT_PARTIAL');
174 my $atomtype = $x->atom(name => 'CARDINAL');
183 pack('L12', 0, 0, 0, 16, 0, 0, 0, 0, 0, 1280, 0, 0)
190 @docked = get_dock_clients('bottom');
191 is(@docked, 1, 'dock client on bottom');
196 #####################################################################
197 # regression test: transient dock client
198 #####################################################################
200 my $fwindow = $x->root->create_child(
201 class => WINDOW_CLASS_INPUT_OUTPUT,
202 rect => [ 0, 0, 30, 30],
203 background_color => '#FF0000',
204 window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'),
205 event_mask => [ 'structure_notify' ],
208 $fwindow->transient_for($window);