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