2010-03-05 13:53:33 -05:00
|
|
|
#!perl
|
|
|
|
# vim:ts=4:sw=4:expandtab
|
2012-09-10 08:09:01 -04:00
|
|
|
#
|
|
|
|
# Please read the following documents before working on tests:
|
|
|
|
# • http://build.i3wm.org/docs/testsuite.html
|
|
|
|
# (or docs/testsuite)
|
|
|
|
#
|
|
|
|
# • http://build.i3wm.org/docs/lib-i3test.html
|
|
|
|
# (alternatively: perldoc ./testcases/lib/i3test.pm)
|
|
|
|
#
|
|
|
|
# • http://build.i3wm.org/docs/ipc.html
|
|
|
|
# (or docs/ipc)
|
|
|
|
#
|
|
|
|
# • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
|
|
|
|
# (unless you are already familiar with Perl)
|
2010-03-05 13:53:33 -05:00
|
|
|
|
2011-03-09 14:25:17 -05:00
|
|
|
use i3test;
|
2010-03-05 13:53:33 -05:00
|
|
|
|
2011-03-09 14:25:17 -05:00
|
|
|
my $tmp = fresh_workspace;
|
2010-03-05 13:53:33 -05:00
|
|
|
|
2010-11-12 19:19:21 -05: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.
|
|
|
|
####################################################################################
|
|
|
|
|
2011-11-21 18:47:32 -05:00
|
|
|
my $left = open_window({ name => 'Left' });
|
|
|
|
my $right = open_window({ name => 'Right' });
|
2010-11-12 19:19:21 -05:00
|
|
|
|
|
|
|
my ($abs, $rgeom) = $right->rect;
|
|
|
|
|
2011-11-21 19:00:54 -05:00
|
|
|
my $child = open_floating_window({
|
2011-09-24 10:11:37 -04:00
|
|
|
dont_map => 1,
|
|
|
|
name => 'Child window',
|
|
|
|
});
|
2010-11-12 19:19:21 -05:00
|
|
|
$child->client_leader($right);
|
|
|
|
$child->map;
|
|
|
|
|
2011-11-21 17:44:20 -05:00
|
|
|
ok(wait_for_map($child), 'child window mapped');
|
2010-11-12 19:19:21 -05:00
|
|
|
|
|
|
|
my $cgeom;
|
|
|
|
($abs, $cgeom) = $child->rect;
|
|
|
|
cmp_ok($cgeom->x, '>=', $rgeom->x, 'Child X >= right container X');
|
|
|
|
|
2011-11-21 19:00:54 -05:00
|
|
|
my $child2 = open_floating_window({
|
2011-09-24 10:11:37 -04:00
|
|
|
dont_map => 1,
|
|
|
|
name => 'Child window 2',
|
|
|
|
});
|
2010-11-12 19:19:21 -05:00
|
|
|
$child2->client_leader($left);
|
|
|
|
$child2->map;
|
|
|
|
|
2011-11-21 17:44:20 -05:00
|
|
|
ok(wait_for_map($child2), 'second child window mapped');
|
2010-11-12 19:19:21 -05:00
|
|
|
|
|
|
|
($abs, $cgeom) = $child2->rect;
|
|
|
|
cmp_ok(($cgeom->x + $cgeom->width), '<', $rgeom->x, 'child above left window');
|
|
|
|
|
|
|
|
# check wm_transient_for
|
2011-11-21 18:47:32 -05:00
|
|
|
my $fwindow = open_window({ dont_map => 1 });
|
2010-11-12 19:19:21 -05:00
|
|
|
$fwindow->transient_for($right);
|
|
|
|
$fwindow->map;
|
|
|
|
|
2011-11-21 17:44:20 -05:00
|
|
|
ok(wait_for_map($fwindow), 'transient window mapped');
|
2010-11-12 19:19:21 -05: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 13:53:33 -05:00
|
|
|
#####################################################################
|
|
|
|
# Create a parent window
|
|
|
|
#####################################################################
|
|
|
|
|
2011-11-21 18:47:32 -05:00
|
|
|
my $window = open_window({ dont_map => 1, name => 'Parent window' });
|
2010-03-05 13:53:33 -05:00
|
|
|
$window->map;
|
|
|
|
|
2011-11-21 17:44:20 -05:00
|
|
|
ok(wait_for_map($window), 'parent window mapped');
|
2010-03-05 13:53:33 -05:00
|
|
|
|
|
|
|
#########################################################################
|
2011-03-09 14:25:17 -05:00
|
|
|
# Switch to a different workspace and open a child window. It should be opened
|
|
|
|
# on the old workspace.
|
2010-03-05 13:53:33 -05:00
|
|
|
#########################################################################
|
2011-03-09 14:25:17 -05:00
|
|
|
fresh_workspace;
|
2010-03-05 13:53:33 -05:00
|
|
|
|
2011-11-21 18:47:32 -05:00
|
|
|
my $child = open_window({ dont_map => 1, name => 'Child window' });
|
2010-03-05 13:53:33 -05:00
|
|
|
$child->client_leader($window);
|
|
|
|
$child->map;
|
|
|
|
|
2011-11-21 17:44:20 -05:00
|
|
|
ok(wait_for_map($child), 'child window mapped');
|
2010-03-05 13:53:33 -05:00
|
|
|
|
|
|
|
isnt($x->input_focus, $child->id, "Child window focused");
|
|
|
|
|
|
|
|
# Switch back
|
2011-03-09 14:25:17 -05:00
|
|
|
cmd "workspace $tmp";
|
2010-03-05 13:53:33 -05:00
|
|
|
|
|
|
|
is($x->input_focus, $child->id, "Child window focused");
|
2010-11-12 19:19:21 -05:00
|
|
|
|
|
|
|
}
|
2011-03-09 14:25:17 -05:00
|
|
|
|
2014-08-26 04:00:14 -04:00
|
|
|
################################################################################
|
|
|
|
# Verify that transient_for can be set and unset.
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
$tmp = fresh_workspace;
|
|
|
|
|
|
|
|
$fwindow = open_window({ dont_map => 1 });
|
|
|
|
$fwindow->transient_for($right);
|
|
|
|
$fwindow->map;
|
|
|
|
|
2014-10-02 17:07:50 -04:00
|
|
|
wait_for_map($fwindow);
|
|
|
|
|
2014-08-26 04:00:14 -04:00
|
|
|
my $floating_con = get_ws($tmp)->{floating_nodes}[0]->{nodes}[0];
|
|
|
|
is($floating_con->{window_properties}->{transient_for}, $right->id, 'WM_TRANSIENT_FOR properly parsed');
|
|
|
|
|
|
|
|
$x->delete_property($fwindow->id, $x->atom(name => 'WM_TRANSIENT_FOR')->id);
|
|
|
|
$x->flush;
|
|
|
|
|
|
|
|
sync_with_i3;
|
|
|
|
|
|
|
|
$floating_con = get_ws($tmp)->{floating_nodes}[0]->{nodes}[0];
|
|
|
|
is($floating_con->{window_properties}->{transient_for}, undef, 'WM_TRANSIENT_FOR properly removed');
|
|
|
|
|
2011-03-09 14:25:17 -05:00
|
|
|
done_testing;
|