2 # vim:ts=4:sw=4:expandtab
4 # Checks if the 'move workspace' command works correctly
8 my $i3 = i3(get_socket_path());
10 # We move the pointer out of our way to avoid a bug where the focus will
11 # be set to the window under the cursor
12 my $x = X11::XCB::Connection->new;
13 $x->root->warp_pointer(0, 0);
15 my $tmp = get_unused_workspace();
16 my $tmp2 = get_unused_workspace();
19 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
21 my $first = open_empty_con($i3);
22 my $second = open_empty_con($i3);
23 ok(@{get_ws_content($tmp)} == 2, 'two containers on first ws');
25 cmd "workspace $tmp2";
26 ok(@{get_ws_content($tmp2)} == 0, 'no containers on second ws yet');
30 cmd "move workspace $tmp2";
31 ok(@{get_ws_content($tmp)} == 1, 'one container on first ws anymore');
32 ok(@{get_ws_content($tmp2)} == 1, 'one container on second ws');
33 my ($nodes, $focus) = get_ws_content($tmp2);
35 is($focus->[0], $second, 'same container on different ws');
37 ($nodes, $focus) = get_ws_content($tmp);
38 ok($nodes->[0]->{focused}, 'first container focused on first ws');
40 ###################################################################
41 # check if 'move workspace next' and 'move workspace prev' work
42 ###################################################################
44 # Open two containers on the first workspace, one container on the second
45 # workspace. Because the workspaces are named, they will be sorted by order of
47 $tmp = get_unused_workspace();
48 $tmp2 = get_unused_workspace();
50 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
51 $first = open_empty_con($i3);
52 $second = open_empty_con($i3);
53 ok(@{get_ws_content($tmp)} == 2, 'two containers on first ws');
55 cmd "workspace $tmp2";
56 ok(@{get_ws_content($tmp2)} == 0, 'no containers yet');
57 my $third = open_empty_con($i3);
58 ok(@{get_ws_content($tmp2)} == 1, 'one container on second ws');
60 # go back to the first workspace, move one of the containers to the next one
62 cmd 'move workspace next';
63 ok(@{get_ws_content($tmp)} == 1, 'one container on first ws');
64 ok(@{get_ws_content($tmp2)} == 2, 'two containers on second ws');
66 # go to the second workspace and move two containers to the first one
67 cmd "workspace $tmp2";
68 cmd 'move workspace prev';
69 cmd 'move workspace prev';
70 ok(@{get_ws_content($tmp)} == 3, 'three containers on first ws');
71 ok(@{get_ws_content($tmp2)} == 0, 'no containers on second ws');
73 ###################################################################
74 # check if floating cons are moved to new workspaces properly
75 # (that is, if they are floating on the target ws, too)
76 ###################################################################
78 $tmp = get_unused_workspace();
79 $tmp2 = get_unused_workspace();
83 cmd "floating toggle";
85 my $ws = get_ws($tmp);
86 is(@{$ws->{nodes}}, 0, 'no nodes on workspace');
87 is(@{$ws->{floating_nodes}}, 1, 'one floating node on workspace');
89 cmd "move workspace $tmp2";
92 is(@{$ws->{nodes}}, 0, 'no nodes on workspace');
93 is(@{$ws->{floating_nodes}}, 1, 'one floating node on workspace');