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