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