2 # vim:ts=4:sw=4:expandtab
4 use Test::More tests => 16;
9 use lib "$FindBin::Bin/lib";
12 use List::Util qw(first);
15 # We use relatively long sleeps (1/4 second) to make sure the window manager
17 use Time::HiRes qw(sleep);
19 my $i3 = i3("/tmp/nestedcons");
21 my $tmp = get_unused_workspace();
22 $i3->command("workspace $tmp")->recv;
24 # get the output of this workspace
25 my $tree = $i3->get_workspaces->recv;
26 my @outputs = @{$tree->{nodes}};
27 my $output = first { defined(first { $_->{name} eq $tmp } @{$_->{nodes}}) } @outputs;
30 use_ok('X11::XCB::Window');
33 my $x = X11::XCB::Connection->new;
35 my $original_rect = X11::XCB::Rect->new(x => 0, y => 0, width => 30, height => 30);
37 my $window = $x->root->create_child(
38 class => WINDOW_CLASS_INPUT_OUTPUT,
39 rect => $original_rect,
40 background_color => '#C0C0C0',
43 isa_ok($window, 'X11::XCB::Window');
45 is_deeply($window->rect, $original_rect, "rect unmodified before mapping");
51 # open another container to make the window get only half of the screen
52 $i3->command('open')->recv;
54 my $new_rect = $window->rect;
55 ok(!eq_deeply($new_rect, $original_rect), "Window got repositioned");
56 $original_rect = $new_rect;
60 $window->fullscreen(1);
64 $new_rect = $window->rect;
65 ok(!eq_deeply($new_rect, $original_rect), "Window got repositioned after fullscreen");
67 my $orect = $output->{rect};
68 my $wrect = $new_rect;
70 # see if the window really is fullscreen. 20 px for borders are allowed
72 ok(($wrect->{x} - $orect->{x}) < $threshold, 'x coordinate fullscreen');
73 ok(($wrect->{y} - $orect->{y}) < $threshold, 'y coordinate fullscreen');
74 ok(abs($wrect->{width} - $orect->{width}) < $threshold, 'width coordinate fullscreen');
75 ok(abs($wrect->{height} - $orect->{height}) < $threshold, 'height coordinate fullscreen');
79 # open another container because the empty one will swallow the window we
81 $i3->command('open')->recv;
83 $window = $x->root->create_child(
84 class => WINDOW_CLASS_INPUT_OUTPUT,
85 rect => $original_rect,
86 background_color => 61440,
89 is_deeply($window->rect, $original_rect, "rect unmodified before mapping");
91 $window->fullscreen(1);
96 $new_rect = $window->rect;
97 ok(!eq_deeply($new_rect, $original_rect), "Window got repositioned after fullscreen");
98 ok($window->mapped, "Window is mapped after opening it in fullscreen mode");
102 # see if the window really is fullscreen. 20 px for borders are allowed
104 ok(($wrect->{x} - $orect->{x}) < $threshold, 'x coordinate fullscreen');
105 ok(($wrect->{y} - $orect->{y}) < $threshold, 'y coordinate fullscreen');
106 ok(abs($wrect->{width} - $orect->{width}) < $threshold, 'width coordinate fullscreen');
107 ok(abs($wrect->{height} - $orect->{height}) < $threshold, 'height coordinate fullscreen');
109 diag( "Testing i3, Perl $], $^X" );