]> git.sur5r.net Git - i3/i3/blob - testcases/t/114-client-leader.t
Merge branch 'master' into next
[i3/i3] / testcases / t / 114-client-leader.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3
4 use i3test;
5
6 my $tmp = fresh_workspace;
7
8 ####################################################################################
9 # first part: test if a floating window will be correctly positioned above its leader
10 #
11 # This is verified by opening two windows, then opening a floating window above the
12 # right one, then above the left one. If the floating windows are all positioned alike,
13 # one of both (depending on your screen resolution) will be positioned wrong.
14 ####################################################################################
15
16 my $left = open_window({ name => 'Left' });
17 my $right = open_window({ name => 'Right' });
18
19 my ($abs, $rgeom) = $right->rect;
20
21 my $child = open_floating_window({
22         dont_map => 1,
23         name => 'Child window',
24     });
25 $child->client_leader($right);
26 $child->map;
27
28 ok(wait_for_map($child), 'child window mapped');
29
30 my $cgeom;
31 ($abs, $cgeom) = $child->rect;
32 cmp_ok($cgeom->x, '>=', $rgeom->x, 'Child X >= right container X');
33
34 my $child2 = open_floating_window({
35         dont_map => 1,
36         name => 'Child window 2',
37     });
38 $child2->client_leader($left);
39 $child2->map;
40
41 ok(wait_for_map($child2), 'second child window mapped');
42
43 ($abs, $cgeom) = $child2->rect;
44 cmp_ok(($cgeom->x + $cgeom->width), '<', $rgeom->x, 'child above left window');
45
46 # check wm_transient_for
47 my $fwindow = open_window({ dont_map => 1 });
48 $fwindow->transient_for($right);
49 $fwindow->map;
50
51 ok(wait_for_map($fwindow), 'transient window mapped');
52
53 my ($absolute, $top) = $fwindow->rect;
54 ok($absolute->{x} != 0 && $absolute->{y} != 0, 'i3 did not map it to (0x0)');
55
56 SKIP: {
57     skip "(workspace placement by client_leader not yet implemented)", 3;
58
59 #####################################################################
60 # Create a parent window
61 #####################################################################
62
63 my $window = open_window({ dont_map => 1, name => 'Parent window' });
64 $window->map;
65
66 ok(wait_for_map($window), 'parent window mapped');
67
68 #########################################################################
69 # Switch to a different workspace and open a child window. It should be opened
70 # on the old workspace.
71 #########################################################################
72 fresh_workspace;
73
74 my $child = open_window({ dont_map => 1, name => 'Child window' });
75 $child->client_leader($window);
76 $child->map;
77
78 ok(wait_for_map($child), 'child window mapped');
79
80 isnt($x->input_focus, $child->id, "Child window focused");
81
82 # Switch back
83 cmd "workspace $tmp";
84
85 is($x->input_focus, $child->id, "Child window focused");
86
87 }
88
89 done_testing;