]> git.sur5r.net Git - i3/i3/blob - testcases/t/14-client-leader.t
implement support for WM_TRANSIENT_FOR, expand testcase
[i3/i3] / testcases / t / 14-client-leader.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3
4 use i3test tests => 7;
5 use X11::XCB qw(:all);
6 use Time::HiRes qw(sleep);
7
8 BEGIN {
9     use_ok('X11::XCB::Connection') or BAIL_OUT('Cannot load X11::XCB::Connection');
10 }
11
12 my $x = X11::XCB::Connection->new;
13 my $i3 = i3("/tmp/nestedcons");
14
15 my $tmp = get_unused_workspace();
16 $i3->command("workspace $tmp")->recv;
17
18 ####################################################################################
19 # first part: test if a floating window will be correctly positioned above its leader
20 #
21 # This is verified by opening two windows, then opening a floating window above the
22 # right one, then above the left one. If the floating windows are all positioned alike,
23 # one of both (depending on your screen resolution) will be positioned wrong.
24 ####################################################################################
25
26 my $left = $x->root->create_child(
27     class => WINDOW_CLASS_INPUT_OUTPUT,
28     rect => [0, 0, 30, 30],
29     background_color => '#FF0000',
30 );
31
32 $left->name('Left');
33 $left->map;
34
35 my $right = $x->root->create_child(
36     class => WINDOW_CLASS_INPUT_OUTPUT,
37     rect => [0, 0, 30, 30],
38     background_color => '#FF0000',
39 );
40
41 $right->name('Right');
42 $right->map;
43
44 sleep 0.25;
45
46 my ($abs, $rgeom) = $right->rect;
47
48 my $child = $x->root->create_child(
49     class => WINDOW_CLASS_INPUT_OUTPUT,
50     rect => [ 0, 0, 30, 30 ],
51     background_color => '#C0C0C0',
52     window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_UTILITY'),
53 );
54
55 $child->name('Child window');
56 $child->client_leader($right);
57 $child->map;
58
59 sleep 0.25;
60
61 my $cgeom;
62 ($abs, $cgeom) = $child->rect;
63 cmp_ok($cgeom->x, '>=', $rgeom->x, 'Child X >= right container X');
64
65 my $child2 = $x->root->create_child(
66     class => WINDOW_CLASS_INPUT_OUTPUT,
67     rect => [ 0, 0, 30, 30 ],
68     background_color => '#C0C0C0',
69     window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_UTILITY'),
70 );
71
72 $child2->name('Child window 2');
73 $child2->client_leader($left);
74 $child2->map;
75
76 sleep 0.25;
77
78 ($abs, $cgeom) = $child2->rect;
79 cmp_ok(($cgeom->x + $cgeom->width), '<', $rgeom->x, 'child above left window');
80
81 # check wm_transient_for
82
83
84 my $fwindow = $x->root->create_child(
85     class => WINDOW_CLASS_INPUT_OUTPUT,
86     rect => [ 0, 0, 30, 30],
87     background_color => '#FF0000',
88 );
89
90 $fwindow->transient_for($right);
91 $fwindow->map;
92
93 sleep 0.25;
94
95 my ($absolute, $top) = $fwindow->rect;
96 ok($absolute->{x} != 0 && $absolute->{y} != 0, 'i3 did not map it to (0x0)');
97
98 SKIP: {
99     skip "(workspace placement by client_leader not yet implemented)", 3;
100
101 #####################################################################
102 # Create a parent window
103 #####################################################################
104
105 my $window = $x->root->create_child(
106 class => WINDOW_CLASS_INPUT_OUTPUT,
107 rect => [ 0, 0, 30, 30 ],
108 background_color => '#C0C0C0',
109 );
110
111 $window->name('Parent window');
112 $window->map;
113
114 sleep 0.25;
115
116 #########################################################################
117 # Switch workspace to 10 and open a child window. It should be positioned
118 # on workspace 9.
119 #########################################################################
120 my $otmp = get_unused_workspace();
121 $i3->command("workspace $otmp")->recv;
122
123 my $child = $x->root->create_child(
124 class => WINDOW_CLASS_INPUT_OUTPUT,
125 rect => [ 0, 0, 30, 30 ],
126 background_color => '#C0C0C0',
127 );
128
129 $child->name('Child window');
130 $child->client_leader($window);
131 $child->map;
132
133 sleep 0.25;
134
135 isnt($x->input_focus, $child->id, "Child window focused");
136
137 # Switch back
138 $i3->command("workspace $tmp")->recv;
139
140 is($x->input_focus, $child->id, "Child window focused");
141
142 }