2 # vim:ts=4:sw=4:expandtab
4 # Please read the following documents before working on tests:
5 # • https://build.i3wm.org/docs/testsuite.html
8 # • https://build.i3wm.org/docs/lib-i3test.html
9 # (alternatively: perldoc ./testcases/lib/i3test.pm)
11 # • https://build.i3wm.org/docs/ipc.html
14 # • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
15 # (unless you are already familiar with Perl)
17 # Tests sticky windows.
19 use i3test i3_config => <<EOT;
21 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
23 workspace ws-on-0 output fake-0
25 fake-outputs 1024x768+0+0,1024x768+1024+0
28 my ($ws, $tmp, $focused);
30 ###############################################################################
31 # 1: Given a sticky tiling container, when the workspace is switched, then
33 ###############################################################################
37 $ws = fresh_workspace;
39 is(@{get_ws($ws)->{nodes}}, 0, 'tiling sticky container did not move');
40 is(@{get_ws($ws)->{floating_nodes}}, 0, 'tiling sticky container did not move');
43 ###############################################################################
44 # 2: Given a sticky floating container, when the workspace is switched, then
45 # the container moves to the new workspace.
46 ###############################################################################
47 $ws = fresh_workspace;
49 $focused = get_focused($ws);
51 $ws = fresh_workspace;
53 is(@{get_ws($ws)->{floating_nodes}}, 1, 'floating sticky container moved to new workspace');
54 is(get_focused($ws), $focused, 'sticky container has focus');
57 ###############################################################################
58 # 3: Given two sticky floating containers, when the workspace is switched,
59 # then both containers move to the new workspace.
60 ###############################################################################
66 $ws = fresh_workspace;
68 is(@{get_ws($ws)->{floating_nodes}}, 2, 'multiple sticky windows can be used at the same time');
71 ###############################################################################
72 # 4: Given an unfocused sticky floating container and a tiling container on the
73 # target workspace, when the workspace is switched, then the tiling container
75 ###############################################################################
76 $ws = fresh_workspace;
78 $focused = get_focused($ws);
83 cmd 'workspace ' . $ws;
85 is(get_focused($ws), $focused, 'the tiling container has focus');
88 ###############################################################################
89 # 5: Given a focused sticky floating container and a tiling container on the
90 # target workspace, when the workspace is switched, then the tiling container
92 ###############################################################################
93 $ws = fresh_workspace;
95 $tmp = fresh_workspace;
97 $focused = get_focused($tmp);
99 cmd 'workspace ' . $ws;
101 is(get_focused($ws), $focused, 'the sticky container has focus');
104 ###############################################################################
105 # 6: Given a floating container on a non-visible workspace, when the window
106 # is made sticky, then the window immediately jumps to the currently
108 ###############################################################################
110 open_floating_window;
112 $ws = fresh_workspace;
113 cmd '[con_mark=sticky] sticky enable';
115 is(@{get_ws($ws)->{floating_nodes}}, 1, 'the sticky window jumps to the front');
118 ###############################################################################
119 # 7: Given a sticky floating container and a workspace on another output, when
120 # a new workspace assigned to the first output is focused, then the sticky
121 # container should jump to the new workspace and have input focus correctly.
122 ###############################################################################
123 $ws = fresh_workspace(output => 0);
124 open_floating_window;
125 cmd 'sticky enabled';
126 $focused = get_focused($ws);
127 $ws = fresh_workspace(output => 1);
129 is(@{get_ws($ws)->{floating_nodes}}, 0, 'the sticky window didn\'t jump to a workspace on a different output');
132 is(@{get_ws($ws)->{floating_nodes}}, 1, 'the sticky window moved to new workspace on first output');
133 is(get_focused($ws), $focused, 'the sticky window has focus');
136 ###############################################################################