]> git.sur5r.net Git - i3/i3/blob - testcases/t/38-floating-attach.t
Merge branch 'master' into next
[i3/i3] / testcases / t / 38-floating-attach.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3 # Regression test: New windows were attached to the container of a floating window
4 # if only a floating window is present on the workspace.
5
6 use i3test;
7 use X11::XCB qw(:all);
8 use Time::HiRes qw(sleep);
9
10 BEGIN {
11     use_ok('X11::XCB::Window');
12 }
13
14 my $i3 = i3(get_socket_path());
15
16 my $tmp = fresh_workspace;
17
18 #############################################################################
19 # 1: open a floating window, get it mapped
20 #############################################################################
21
22 my $x = X11::XCB::Connection->new;
23
24 # Create a floating window
25 my $window = $x->root->create_child(
26     class => WINDOW_CLASS_INPUT_OUTPUT,
27     rect => [ 0, 0, 30, 30],
28     background_color => '#C0C0C0',
29     # replace the type with 'utility' as soon as the coercion works again in X11::XCB
30     window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_UTILITY'),
31 );
32
33 isa_ok($window, 'X11::XCB::Window');
34
35 $window->map;
36
37 sleep 0.25;
38
39 ok($window->mapped, 'Window is mapped');
40
41 my $ws = get_ws($tmp);
42 my ($nodes, $focus) = get_ws_content($tmp);
43
44 is(@{$ws->{floating_nodes}}, 1, 'one floating node');
45 is(@{$nodes}, 0, 'no tiling nodes');
46
47 # Create a tiling window
48 my $twindow = $x->root->create_child(
49     class => WINDOW_CLASS_INPUT_OUTPUT,
50     rect => [ 0, 0, 30, 30],
51     background_color => '#C0C0C0',
52 );
53
54 isa_ok($twindow, 'X11::XCB::Window');
55
56 $twindow->map;
57
58 sleep 0.25;
59
60 ($nodes, $focus) = get_ws_content($tmp);
61
62 is(@{$nodes}, 1, 'one tiling node');
63
64 #############################################################################
65 # 2: similar case: floating windows should be attached at the currently focused
66 # position in the workspace (for example a stack), not just at workspace level.
67 #############################################################################
68
69 $tmp = fresh_workspace;
70
71 my $first = open_standard_window($x);
72 my $second = open_standard_window($x);
73
74 cmd 'layout stacked';
75
76 $ws = get_ws($tmp);
77 is(@{$ws->{floating_nodes}}, 0, 'no floating nodes so far');
78 is(@{$ws->{nodes}}, 1, 'one tiling node (stacked con)');
79
80 # Create a floating window
81 my $window = $x->root->create_child(
82     class => WINDOW_CLASS_INPUT_OUTPUT,
83     rect => [ 0, 0, 30, 30],
84     background_color => '#C0C0C0',
85     # replace the type with 'utility' as soon as the coercion works again in X11::XCB
86     window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_UTILITY'),
87 );
88
89 isa_ok($window, 'X11::XCB::Window');
90
91 $window->map;
92
93 sleep 0.25;
94
95 ok($window->mapped, 'Window is mapped');
96
97 $ws = get_ws($tmp);
98 is(@{$ws->{floating_nodes}}, 1, 'one floating nodes');
99 is(@{$ws->{nodes}}, 1, 'one tiling node (stacked con)');
100
101 my $third = open_standard_window($x);
102
103
104 $ws = get_ws($tmp);
105 is(@{$ws->{floating_nodes}}, 1, 'one floating nodes');
106 is(@{$ws->{nodes}}, 1, 'one tiling node (stacked con)');
107
108 done_testing;