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.
8 use Time::HiRes qw(sleep);
11 use_ok('X11::XCB::Window');
14 my $i3 = i3(get_socket_path());
16 my $tmp = fresh_workspace;
18 #############################################################################
19 # 1: open a floating window, get it mapped
20 #############################################################################
22 my $x = X11::XCB::Connection->new;
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'),
33 isa_ok($window, 'X11::XCB::Window');
39 ok($window->mapped, 'Window is mapped');
41 my $ws = get_ws($tmp);
42 my ($nodes, $focus) = get_ws_content($tmp);
44 is(@{$ws->{floating_nodes}}, 1, 'one floating node');
45 is(@{$nodes}, 0, 'no tiling nodes');
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',
54 isa_ok($twindow, 'X11::XCB::Window');
60 ($nodes, $focus) = get_ws_content($tmp);
62 is(@{$nodes}, 1, 'one tiling node');
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 #############################################################################
69 $tmp = fresh_workspace;
71 my $first = open_standard_window($x);
72 my $second = open_standard_window($x);
77 is(@{$ws->{floating_nodes}}, 0, 'no floating nodes so far');
78 is(@{$ws->{nodes}}, 1, 'one tiling node (stacked con)');
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'),
89 isa_ok($window, 'X11::XCB::Window');
95 ok($window->mapped, 'Window is mapped');
98 is(@{$ws->{floating_nodes}}, 1, 'one floating nodes');
99 is(@{$ws->{nodes}}, 1, 'one tiling node (stacked con)');
101 my $third = open_standard_window($x);
105 is(@{$ws->{floating_nodes}}, 1, 'one floating nodes');
106 is(@{$ws->{nodes}}, 1, 'one tiling node (stacked con)');