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;
13 my $i3 = i3("/tmp/nestedcons");
15 #####################################################################
16 # verify that there is no dock window yet
17 #####################################################################
19 # Children of all dockareas
20 my @docked = get_dock_clients;
21 is(@docked, 0, 'no dock clients yet');
23 #####################################################################
24 # Create a dock window and see if it gets managed
25 #####################################################################
27 my $screens = $x->screens;
29 # Get the primary screen
30 my $primary = first { $_->primary } @{$screens};
32 # TODO: focus the primary screen before
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'),
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');
68 @docked = get_dock_clients();
69 is(@docked, 0, 'no more dock clients');
71 #####################################################################
72 # check if it gets placed on bottom (by coordinates)
73 #####################################################################
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'),
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');
90 @docked = get_dock_clients('bottom');
91 is(@docked, 1, 'dock client on bottom');
97 @docked = get_dock_clients();
98 is(@docked, 0, 'no more dock clients');
100 #####################################################################
101 # check if it gets placed on bottom (by hint)
102 #####################################################################
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'),
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');
124 pack('L12', 0, 0, 16, 0, 0, 0, 0, 0, 0, 1280, 0, 0)
131 @docked = get_dock_clients('top');
132 is(@docked, 1, 'dock client on top');
138 @docked = get_dock_clients();
139 is(@docked, 0, 'no more dock clients');
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'),
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');
161 pack('L12', 0, 0, 0, 16, 0, 0, 0, 0, 0, 1280, 0, 0)
168 @docked = get_dock_clients('bottom');
169 is(@docked, 1, 'dock client on bottom');
174 #####################################################################
175 # regression test: transient dock client
176 #####################################################################
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'),
185 $fwindow->transient_for($window);