2 # vim:ts=4:sw=4:expandtab
6 use Time::HiRes qw(sleep);
7 use List::Util qw(first);
10 use_ok('X11::XCB::Connection') or BAIL_OUT('Cannot load X11::XCB::Connection');
13 my $x = X11::XCB::Connection->new;
14 my $i3 = i3("/tmp/nestedcons");
16 #####################################################################
17 # verify that there is no dock window yet
18 #####################################################################
20 # Children of all dockareas
21 my @docked = get_dock_clients;
22 is(@docked, 0, 'no dock clients yet');
24 #####################################################################
25 # Create a dock window and see if it gets managed
26 #####################################################################
28 my $screens = $x->screens;
30 # Get the primary screen
31 my $primary = first { $_->primary } @{$screens};
33 # TODO: focus the primary screen before
35 my $window = $x->root->create_child(
36 class => WINDOW_CLASS_INPUT_OUTPUT,
37 rect => [ 0, 0, 30, 30],
38 background_color => '#FF0000',
39 window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'),
46 my $rect = $window->rect;
47 is($rect->width, $primary->rect->width, 'dock client is as wide as the screen');
48 is($rect->height, 30, 'height is unchanged');
50 #####################################################################
51 # check that we can find it in the layout tree at the expected position
52 #####################################################################
54 @docked = get_dock_clients;
55 is(@docked, 1, 'one dock client found');
57 # verify the position/size
58 my $docknode = $docked[0];
60 is($docknode->{rect}->{x}, 0, 'dock node placed at x=0');
61 is($docknode->{rect}->{y}, 0, 'dock node placed at y=0');
62 is($docknode->{rect}->{width}, $primary->rect->width, 'dock node as wide as the screen');
63 is($docknode->{rect}->{height}, 30, 'dock node has unchanged height');
65 #####################################################################
66 # regression test: transient dock client
67 #####################################################################
69 my $fwindow = $x->root->create_child(
70 class => WINDOW_CLASS_INPUT_OUTPUT,
71 rect => [ 0, 0, 30, 30],
72 background_color => '#FF0000',
73 window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'),
76 $fwindow->transient_for($window);