2010-03-05 19:53:33 +01:00
|
|
|
#!perl
|
|
|
|
# vim:ts=4:sw=4:expandtab
|
|
|
|
|
2011-03-09 20:25:17 +01:00
|
|
|
use i3test;
|
2010-03-05 19:53:33 +01:00
|
|
|
use X11::XCB qw(:all);
|
|
|
|
|
|
|
|
BEGIN {
|
|
|
|
use_ok('X11::XCB::Connection') or BAIL_OUT('Cannot load X11::XCB::Connection');
|
|
|
|
}
|
|
|
|
|
|
|
|
my $x = X11::XCB::Connection->new;
|
|
|
|
|
2011-03-09 20:25:17 +01:00
|
|
|
my $tmp = fresh_workspace;
|
2010-03-05 19:53:33 +01:00
|
|
|
|
2010-11-13 01:19:21 +01:00
|
|
|
####################################################################################
|
|
|
|
# first part: test if a floating window will be correctly positioned above its leader
|
|
|
|
#
|
|
|
|
# This is verified by opening two windows, then opening a floating window above the
|
|
|
|
# right one, then above the left one. If the floating windows are all positioned alike,
|
|
|
|
# one of both (depending on your screen resolution) will be positioned wrong.
|
|
|
|
####################################################################################
|
|
|
|
|
|
|
|
my $left = $x->root->create_child(
|
|
|
|
class => WINDOW_CLASS_INPUT_OUTPUT,
|
|
|
|
rect => [0, 0, 30, 30],
|
|
|
|
background_color => '#FF0000',
|
2011-09-24 14:08:02 +02:00
|
|
|
event_mask => [ 'structure_notify' ],
|
2010-11-13 01:19:21 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
$left->name('Left');
|
|
|
|
$left->map;
|
|
|
|
|
|
|
|
my $right = $x->root->create_child(
|
|
|
|
class => WINDOW_CLASS_INPUT_OUTPUT,
|
|
|
|
rect => [0, 0, 30, 30],
|
|
|
|
background_color => '#FF0000',
|
2011-09-24 14:08:02 +02:00
|
|
|
event_mask => [ 'structure_notify' ],
|
2010-11-13 01:19:21 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
$right->name('Right');
|
|
|
|
$right->map;
|
|
|
|
|
2011-09-24 14:08:02 +02:00
|
|
|
ok(wait_for_map($x), 'left window mapped');
|
|
|
|
ok(wait_for_map($x), 'right window mapped');
|
2010-11-13 01:19:21 +01:00
|
|
|
|
|
|
|
my ($abs, $rgeom) = $right->rect;
|
|
|
|
|
|
|
|
my $child = $x->root->create_child(
|
|
|
|
class => WINDOW_CLASS_INPUT_OUTPUT,
|
|
|
|
rect => [ 0, 0, 30, 30 ],
|
|
|
|
background_color => '#C0C0C0',
|
|
|
|
window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_UTILITY'),
|
2011-09-24 14:08:02 +02:00
|
|
|
event_mask => [ 'structure_notify' ],
|
2010-11-13 01:19:21 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
$child->name('Child window');
|
|
|
|
$child->client_leader($right);
|
|
|
|
$child->map;
|
|
|
|
|
2011-09-24 14:08:02 +02:00
|
|
|
ok(wait_for_map($x), 'child window mapped');
|
2010-11-13 01:19:21 +01:00
|
|
|
|
|
|
|
my $cgeom;
|
|
|
|
($abs, $cgeom) = $child->rect;
|
|
|
|
cmp_ok($cgeom->x, '>=', $rgeom->x, 'Child X >= right container X');
|
|
|
|
|
|
|
|
my $child2 = $x->root->create_child(
|
|
|
|
class => WINDOW_CLASS_INPUT_OUTPUT,
|
|
|
|
rect => [ 0, 0, 30, 30 ],
|
|
|
|
background_color => '#C0C0C0',
|
|
|
|
window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_UTILITY'),
|
2011-09-24 14:08:02 +02:00
|
|
|
event_mask => [ 'structure_notify' ],
|
2010-11-13 01:19:21 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
$child2->name('Child window 2');
|
|
|
|
$child2->client_leader($left);
|
|
|
|
$child2->map;
|
|
|
|
|
2011-09-24 14:08:02 +02:00
|
|
|
ok(wait_for_map($x), 'second child window mapped');
|
2010-11-13 01:19:21 +01:00
|
|
|
|
|
|
|
($abs, $cgeom) = $child2->rect;
|
|
|
|
cmp_ok(($cgeom->x + $cgeom->width), '<', $rgeom->x, 'child above left window');
|
|
|
|
|
|
|
|
# check wm_transient_for
|
|
|
|
|
|
|
|
|
|
|
|
my $fwindow = $x->root->create_child(
|
|
|
|
class => WINDOW_CLASS_INPUT_OUTPUT,
|
|
|
|
rect => [ 0, 0, 30, 30],
|
|
|
|
background_color => '#FF0000',
|
2011-09-24 14:08:02 +02:00
|
|
|
event_mask => [ 'structure_notify' ],
|
2010-11-13 01:19:21 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
$fwindow->transient_for($right);
|
|
|
|
$fwindow->map;
|
|
|
|
|
2011-09-24 14:08:02 +02:00
|
|
|
ok(wait_for_map($x), 'transient window mapped');
|
2010-11-13 01:19:21 +01:00
|
|
|
|
|
|
|
my ($absolute, $top) = $fwindow->rect;
|
|
|
|
ok($absolute->{x} != 0 && $absolute->{y} != 0, 'i3 did not map it to (0x0)');
|
|
|
|
|
|
|
|
SKIP: {
|
|
|
|
skip "(workspace placement by client_leader not yet implemented)", 3;
|
|
|
|
|
2010-03-05 19:53:33 +01:00
|
|
|
#####################################################################
|
|
|
|
# Create a parent window
|
|
|
|
#####################################################################
|
|
|
|
|
|
|
|
my $window = $x->root->create_child(
|
2011-09-24 14:08:02 +02:00
|
|
|
class => WINDOW_CLASS_INPUT_OUTPUT,
|
|
|
|
rect => [ 0, 0, 30, 30 ],
|
|
|
|
background_color => '#C0C0C0',
|
|
|
|
event_mask => [ 'structure_notify' ],
|
2010-03-05 19:53:33 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
$window->name('Parent window');
|
|
|
|
$window->map;
|
|
|
|
|
2011-09-24 14:08:02 +02:00
|
|
|
ok(wait_for_map($x), 'parent window mapped');
|
2010-03-05 19:53:33 +01:00
|
|
|
|
|
|
|
#########################################################################
|
2011-03-09 20:25:17 +01:00
|
|
|
# Switch to a different workspace and open a child window. It should be opened
|
|
|
|
# on the old workspace.
|
2010-03-05 19:53:33 +01:00
|
|
|
#########################################################################
|
2011-03-09 20:25:17 +01:00
|
|
|
fresh_workspace;
|
2010-03-05 19:53:33 +01:00
|
|
|
|
|
|
|
my $child = $x->root->create_child(
|
2011-09-24 14:08:02 +02:00
|
|
|
class => WINDOW_CLASS_INPUT_OUTPUT,
|
|
|
|
rect => [ 0, 0, 30, 30 ],
|
|
|
|
background_color => '#C0C0C0',
|
|
|
|
event_mask => [ 'structure_notify' ],
|
2010-03-05 19:53:33 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
$child->name('Child window');
|
|
|
|
$child->client_leader($window);
|
|
|
|
$child->map;
|
|
|
|
|
2011-09-24 14:08:02 +02:00
|
|
|
ok(wait_for_map($x), 'child window mapped');
|
2010-03-05 19:53:33 +01:00
|
|
|
|
|
|
|
isnt($x->input_focus, $child->id, "Child window focused");
|
|
|
|
|
|
|
|
# Switch back
|
2011-03-09 20:25:17 +01:00
|
|
|
cmd "workspace $tmp";
|
2010-03-05 19:53:33 +01:00
|
|
|
|
|
|
|
is($x->input_focus, $child->id, "Child window focused");
|
2010-11-13 01:19:21 +01:00
|
|
|
|
|
|
|
}
|
2011-03-09 20:25:17 +01:00
|
|
|
|
|
|
|
done_testing;
|