2 # vim:ts=4:sw=4:expandtab
4 # Checks if the 'move [window/container] to 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 $x->root->warp_pointer(0, 0);
14 sub move_workspace_test {
17 my $tmp = get_unused_workspace();
18 my $tmp2 = get_unused_workspace();
21 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
23 my $first = open_empty_con($i3);
24 my $second = open_empty_con($i3);
25 ok(@{get_ws_content($tmp)} == 2, 'two containers on first ws');
27 cmd "workspace $tmp2";
28 ok(@{get_ws_content($tmp2)} == 0, 'no containers on second ws yet');
33 ok(@{get_ws_content($tmp)} == 1, 'one container on first ws anymore');
34 ok(@{get_ws_content($tmp2)} == 1, 'one container on second ws');
35 my ($nodes, $focus) = get_ws_content($tmp2);
37 is($focus->[0], $second, 'same container on different ws');
39 ($nodes, $focus) = get_ws_content($tmp);
40 ok($nodes->[0]->{focused}, 'first container focused on first ws');
43 move_workspace_test('move workspace'); # supported for legacy reasons
44 move_workspace_test('move to workspace');
45 # Those are just synonyms and more verbose ways of saying the same thing:
46 move_workspace_test('move window to workspace');
47 move_workspace_test('move container to workspace');
49 ###################################################################
50 # check if 'move workspace next' and 'move workspace prev' work
51 ###################################################################
53 # Open two containers on the first workspace, one container on the second
54 # workspace. Because the workspaces are named, they will be sorted by order of
56 my $tmp = get_unused_workspace();
57 my $tmp2 = get_unused_workspace();
59 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
60 my $first = open_empty_con($i3);
61 my $second = open_empty_con($i3);
62 ok(@{get_ws_content($tmp)} == 2, 'two containers on first ws');
64 cmd "workspace $tmp2";
65 ok(@{get_ws_content($tmp2)} == 0, 'no containers yet');
66 my $third = open_empty_con($i3);
67 ok(@{get_ws_content($tmp2)} == 1, 'one container on second ws');
69 # go back to the first workspace, move one of the containers to the next one
71 cmd 'move workspace next';
72 ok(@{get_ws_content($tmp)} == 1, 'one container on first ws');
73 ok(@{get_ws_content($tmp2)} == 2, 'two containers on second ws');
75 # go to the second workspace and move two containers to the first one
76 cmd "workspace $tmp2";
77 cmd 'move workspace prev';
78 cmd 'move workspace prev';
79 ok(@{get_ws_content($tmp)} == 3, 'three containers on first ws');
80 ok(@{get_ws_content($tmp2)} == 0, 'no containers on second ws');
82 ###################################################################
83 # check if floating cons are moved to new workspaces properly
84 # (that is, if they are floating on the target ws, too)
85 ###################################################################
87 $tmp = get_unused_workspace();
88 $tmp2 = get_unused_workspace();
92 cmd "floating toggle";
94 my $ws = get_ws($tmp);
95 is(@{$ws->{nodes}}, 0, 'no nodes on workspace');
96 is(@{$ws->{floating_nodes}}, 1, 'one floating node on workspace');
98 cmd "move workspace $tmp2";
101 is(@{$ws->{nodes}}, 0, 'no nodes on workspace');
102 is(@{$ws->{floating_nodes}}, 1, 'one floating node on workspace');