2 # vim:ts=4:sw=4:expandtab
8 use_ok('X11::XCB::Connection') or BAIL_OUT('Cannot load X11::XCB::Connection');
11 my $x = X11::XCB::Connection->new;
12 my $i3 = i3("/tmp/nestedcons");
14 my $tmp = fresh_workspace;
16 ####################################################################################
17 # first part: test if a floating window will be correctly positioned above its leader
19 # This is verified by opening two windows, then opening a floating window above the
20 # right one, then above the left one. If the floating windows are all positioned alike,
21 # one of both (depending on your screen resolution) will be positioned wrong.
22 ####################################################################################
24 my $left = $x->root->create_child(
25 class => WINDOW_CLASS_INPUT_OUTPUT,
26 rect => [0, 0, 30, 30],
27 background_color => '#FF0000',
33 my $right = $x->root->create_child(
34 class => WINDOW_CLASS_INPUT_OUTPUT,
35 rect => [0, 0, 30, 30],
36 background_color => '#FF0000',
39 $right->name('Right');
44 my ($abs, $rgeom) = $right->rect;
46 my $child = $x->root->create_child(
47 class => WINDOW_CLASS_INPUT_OUTPUT,
48 rect => [ 0, 0, 30, 30 ],
49 background_color => '#C0C0C0',
50 window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_UTILITY'),
53 $child->name('Child window');
54 $child->client_leader($right);
60 ($abs, $cgeom) = $child->rect;
61 cmp_ok($cgeom->x, '>=', $rgeom->x, 'Child X >= right container X');
63 my $child2 = $x->root->create_child(
64 class => WINDOW_CLASS_INPUT_OUTPUT,
65 rect => [ 0, 0, 30, 30 ],
66 background_color => '#C0C0C0',
67 window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_UTILITY'),
70 $child2->name('Child window 2');
71 $child2->client_leader($left);
76 ($abs, $cgeom) = $child2->rect;
77 cmp_ok(($cgeom->x + $cgeom->width), '<', $rgeom->x, 'child above left window');
79 # check wm_transient_for
82 my $fwindow = $x->root->create_child(
83 class => WINDOW_CLASS_INPUT_OUTPUT,
84 rect => [ 0, 0, 30, 30],
85 background_color => '#FF0000',
88 $fwindow->transient_for($right);
93 my ($absolute, $top) = $fwindow->rect;
94 ok($absolute->{x} != 0 && $absolute->{y} != 0, 'i3 did not map it to (0x0)');
97 skip "(workspace placement by client_leader not yet implemented)", 3;
99 #####################################################################
100 # Create a parent window
101 #####################################################################
103 my $window = $x->root->create_child(
104 class => WINDOW_CLASS_INPUT_OUTPUT,
105 rect => [ 0, 0, 30, 30 ],
106 background_color => '#C0C0C0',
109 $window->name('Parent window');
114 #########################################################################
115 # Switch to a different workspace and open a child window. It should be opened
116 # on the old workspace.
117 #########################################################################
120 my $child = $x->root->create_child(
121 class => WINDOW_CLASS_INPUT_OUTPUT,
122 rect => [ 0, 0, 30, 30 ],
123 background_color => '#C0C0C0',
126 $child->name('Child window');
127 $child->client_leader($window);
132 isnt($x->input_focus, $child->id, "Child window focused");
135 cmd "workspace $tmp";
137 is($x->input_focus, $child->id, "Child window focused");