]> git.sur5r.net Git - i3/i3/blob - testcases/t/285-sticky.t
Merge branch 'release-4.16.1'
[i3/i3] / testcases / t / 285-sticky.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3 #
4 # Please read the following documents before working on tests:
5 # • https://build.i3wm.org/docs/testsuite.html
6 #   (or docs/testsuite)
7 #
8 # • https://build.i3wm.org/docs/lib-i3test.html
9 #   (alternatively: perldoc ./testcases/lib/i3test.pm)
10 #
11 # • https://build.i3wm.org/docs/ipc.html
12 #   (or docs/ipc)
13 #
14 # • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
15 #   (unless you are already familiar with Perl)
16 #
17 # Tests sticky windows.
18 # Ticket: #1455
19 use i3test i3_config => <<EOT;
20 # i3 config file (v4)
21 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
22
23 workspace ws-on-0 output fake-0
24
25 fake-outputs 1024x768+0+0,1024x768+1024+0
26 EOT
27
28 my ($ws, $tmp, $focused);
29
30 ###############################################################################
31 # 1: Given a sticky tiling container, when the workspace is switched, then
32 #    nothing happens.
33 ###############################################################################
34 fresh_workspace;
35 open_window;
36 cmd 'sticky enable';
37 $ws = fresh_workspace;
38
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');
41 kill_all_windows;
42
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;
48 open_floating_window;
49 $focused = get_focused($ws);
50 cmd 'sticky enable';
51 $ws = fresh_workspace;
52
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');
55 kill_all_windows;
56
57 ###############################################################################
58 # 3: Given two sticky floating containers, when the workspace is switched,
59 #    then both containers move to the new workspace.
60 ###############################################################################
61 fresh_workspace;
62 open_floating_window;
63 cmd 'sticky enable';
64 open_floating_window;
65 cmd 'sticky enable';
66 $ws = fresh_workspace;
67
68 is(@{get_ws($ws)->{floating_nodes}}, 2, 'multiple sticky windows can be used at the same time');
69 kill_all_windows;
70
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
74 #    is focused.
75 ###############################################################################
76 $ws = fresh_workspace;
77 open_window;
78 $focused = get_focused($ws);
79 fresh_workspace;
80 open_floating_window;
81 cmd 'sticky enable';
82 open_window;
83 cmd 'workspace ' . $ws;
84
85 is(get_focused($ws), $focused, 'the tiling container has focus');
86 kill_all_windows;
87
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
91 #    is focused.
92 ###############################################################################
93 $ws = fresh_workspace;
94 open_window;
95 $tmp = fresh_workspace;
96 open_floating_window;
97 $focused = get_focused($tmp);
98 cmd 'sticky enable';
99 cmd 'workspace ' . $ws;
100
101 is(get_focused($ws), $focused, 'the sticky container has focus');
102 kill_all_windows;
103
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
107 #    visible workspace.
108 ###############################################################################
109 fresh_workspace;
110 open_floating_window;
111 cmd 'mark sticky';
112 $ws = fresh_workspace;
113 cmd '[con_mark=sticky] sticky enable';
114
115 is(@{get_ws($ws)->{floating_nodes}}, 1, 'the sticky window jumps to the front');
116 kill_all_windows;
117
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);
128
129 is(@{get_ws($ws)->{floating_nodes}}, 0, 'the sticky window didn\'t jump to a workspace on a different output');
130 $ws = 'ws-on-0';
131 cmd "workspace $ws";
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');
134 kill_all_windows;
135
136 ###############################################################################
137
138 done_testing;