]> git.sur5r.net Git - i3/i3/blob - testcases/t/005-floating.t
testcases: drop sync_with_i3()s $x parameter, use global
[i3/i3] / testcases / t / 005-floating.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3
4 use i3test;
5 use X11::XCB 'WINDOW_CLASS_INPUT_OUTPUT';
6
7 # Create a floating window which is smaller than the minimum enforced size of i3
8 my $window = $x->root->create_child(
9     class => WINDOW_CLASS_INPUT_OUTPUT,
10     rect => [ 0, 0, 30, 30],
11     background_color => '#C0C0C0',
12     # replace the type with 'utility' as soon as the coercion works again in X11::XCB
13     window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_UTILITY'),
14     event_mask => [ 'structure_notify' ],
15 );
16
17 isa_ok($window, 'X11::XCB::Window');
18
19 $window->map;
20
21 wait_for_map $window;
22
23 my ($absolute, $top) = $window->rect;
24
25 ok($window->mapped, 'Window is mapped');
26 cmp_ok($absolute->{width}, '>=', 75, 'i3 raised the width to 75');
27 cmp_ok($absolute->{height}, '>=', 50, 'i3 raised the height to 50');
28
29 ok($absolute->{x} != 0 && $absolute->{y} != 0, 'i3 did not map it to (0x0)');
30
31 $window->unmap;
32
33 $window = $x->root->create_child(
34     class => WINDOW_CLASS_INPUT_OUTPUT,
35     rect => [ 1, 1, 80, 90],
36     background_color => '#C0C0C0',
37     window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_UTILITY'),
38     event_mask => [ 'structure_notify' ],
39 );
40
41 isa_ok($window, 'X11::XCB::Window');
42
43 $window->map;
44
45 wait_for_map $window;
46
47 ($absolute, $top) = $window->rect;
48
49 cmp_ok($absolute->{width}, '==', 80, "i3 let the width at 80");
50 cmp_ok($absolute->{height}, '==', 90, "i3 let the height at 90");
51
52 # We need to compare the position with decorations due to the way
53 # we do decoration rendering (on the parent frame) in the tree branch
54 cmp_ok($top->{x}, '==', 1, 'i3 mapped it to x=1');
55 cmp_ok($top->{y}, '==', 19, 'i3 mapped it to y=18');
56
57 $window->unmap;
58
59 #####################################################################
60 # check that a tiling window which is then made floating still has
61 # at least the size of its initial geometry
62 #####################################################################
63
64 $window = $x->root->create_child(
65     class => WINDOW_CLASS_INPUT_OUTPUT,
66     rect => [ 1, 1, 80, 90],
67     background_color => '#C0C0C0',
68     #window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_UTILITY'),
69     event_mask => [ 'structure_notify' ],
70 );
71
72 isa_ok($window, 'X11::XCB::Window');
73
74 $window->map;
75
76 wait_for_map $window;
77
78 cmd 'floating enable';
79 sync_with_i3;
80
81 ($absolute, $top) = $window->rect;
82
83 cmp_ok($absolute->{width}, '==', 80, "i3 let the width at 80");
84 cmp_ok($absolute->{height}, '==', 90, "i3 let the height at 90");
85
86 $window->unmap;
87
88 done_testing;