]> git.sur5r.net Git - i3/i3/blob - testcases/t/005-floating.t
Merge branch 'fix-i3bar-multi-dpy'
[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 => [ 20, 20, 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 cmp_ok($top->{x}, '==', 20, 'i3 mapped it to x=20');
59 cmp_ok($top->{y}, '==', 20, 'i3 mapped it to y=20');
60
61 $window->unmap;
62
63 #####################################################################
64 # check that a tiling window which is then made floating still has
65 # at least the size of its initial geometry
66 #####################################################################
67
68 $window = $x->root->create_child(
69     class => WINDOW_CLASS_INPUT_OUTPUT,
70     rect => [ 1, 1, 80, 90],
71     background_color => '#C0C0C0',
72     #window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_UTILITY'),
73     event_mask => [ 'structure_notify' ],
74 );
75
76 isa_ok($window, 'X11::XCB::Window');
77
78 $window->map;
79
80 wait_for_map $x;
81
82 cmd 'floating enable';
83
84 ($absolute, $top) = $window->rect;
85
86 cmp_ok($absolute->{width}, '==', 80, "i3 let the width at 80");
87 cmp_ok($absolute->{height}, '==', 90, "i3 let the height at 90");
88
89 $window->unmap;
90
91 done_testing;