2 # vim:ts=4:sw=4:expandtab
4 # Please read the following documents before working on tests:
5 # • https://build.i3wm.org/docs/testsuite.html
8 # • https://build.i3wm.org/docs/lib-i3test.html
9 # (alternatively: perldoc ./testcases/lib/i3test.pm)
11 # • https://build.i3wm.org/docs/ipc.html
14 # • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
15 # (unless you are already familiar with Perl)
19 my $tmp = fresh_workspace;
21 ####################################################################################
22 # first part: test if a floating window will be correctly positioned above its leader
24 # This is verified by opening two windows, then opening a floating window above the
25 # right one, then above the left one. If the floating windows are all positioned alike,
26 # one of both (depending on your screen resolution) will be positioned wrong.
27 ####################################################################################
29 my $left = open_window({ name => 'Left' });
30 my $right = open_window({ name => 'Right' });
32 my ($abs, $rgeom) = $right->rect;
34 my $child = open_floating_window({
36 name => 'Child window',
38 $child->client_leader($right);
41 ok(wait_for_map($child), 'child window mapped');
44 ($abs, $cgeom) = $child->rect;
45 cmp_ok($cgeom->x, '>=', $rgeom->x, 'Child X >= right container X');
47 my $child2 = open_floating_window({
49 name => 'Child window 2',
51 $child2->client_leader($left);
54 ok(wait_for_map($child2), 'second child window mapped');
56 ($abs, $cgeom) = $child2->rect;
57 cmp_ok(($cgeom->x + $cgeom->width), '<', $rgeom->x, 'child above left window');
59 # check wm_transient_for
60 my $fwindow = open_window({ dont_map => 1 });
61 $fwindow->transient_for($right);
64 ok(wait_for_map($fwindow), 'transient window mapped');
66 my ($absolute, $top) = $fwindow->rect;
67 ok($absolute->{x} != 0 && $absolute->{y} != 0, 'i3 did not map it to (0x0)');
70 skip "(workspace placement by client_leader not yet implemented)", 3;
72 #####################################################################
73 # Create a parent window
74 #####################################################################
76 my $window = open_window({ dont_map => 1, name => 'Parent window' });
79 ok(wait_for_map($window), 'parent window mapped');
81 #########################################################################
82 # Switch to a different workspace and open a child window. It should be opened
83 # on the old workspace.
84 #########################################################################
87 my $child = open_window({ dont_map => 1, name => 'Child window' });
88 $child->client_leader($window);
91 ok(wait_for_map($child), 'child window mapped');
93 isnt($x->input_focus, $child->id, "Child window focused");
98 is($x->input_focus, $child->id, "Child window focused");
102 ################################################################################
103 # Verify that transient_for can be set and unset.
104 ################################################################################
106 $tmp = fresh_workspace;
108 $fwindow = open_window({ dont_map => 1 });
109 $fwindow->transient_for($right);
112 wait_for_map($fwindow);
114 my $floating_con = get_ws($tmp)->{floating_nodes}[0]->{nodes}[0];
115 is($floating_con->{window_properties}->{transient_for}, $right->id, 'WM_TRANSIENT_FOR properly parsed');
117 $x->delete_property($fwindow->id, $x->atom(name => 'WM_TRANSIENT_FOR')->id);
122 $floating_con = get_ws($tmp)->{floating_nodes}[0]->{nodes}[0];
123 is($floating_con->{window_properties}->{transient_for}, undef, 'WM_TRANSIENT_FOR properly removed');