2 # vim:ts=4:sw=4:expandtab
4 # Please read the following documents before working on tests:
5 # • http://build.i3wm.org/docs/testsuite.html
8 # • http://build.i3wm.org/docs/lib-i3test.html
9 # (alternatively: perldoc ./testcases/lib/i3test.pm)
11 # • http://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 for setting and removing the _NET_WM_STATE_HIDDEN atom properly.
20 use X11::XCB qw(:all);
24 my $atom = $x->atom(name => '_NET_WM_STATE_HIDDEN');
27 my $cookie = $x->get_property(
30 $x->atom(name => '_NET_WM_STATE')->id,
31 GET_PROPERTY_TYPE_ANY,
36 my $reply = $x->get_property_reply($cookie->{sequence});
37 my $len = $reply->{length};
38 return 0 if $len == 0;
40 my @atoms = unpack("L$len", $reply->{value});
41 for (my $i = 0; $i < $len; $i++) {
42 return 1 if $atoms[$i] == $atom->id;
48 my ($tabA, $tabB, $tabC, $subtabA, $subtabB, $windowA, $windowB);
50 ###############################################################################
51 # Given two containers next to each other, when focusing one, then the other
52 # one does not have _NET_WM_STATE_HIDDEN set.
53 ###############################################################################
56 $windowA = open_window;
57 $windowB = open_window;
59 ok(!is_hidden($windowA), 'left window does not have _NET_WM_STATE_HIDDEN set');
60 ok(!is_hidden($windowB), 'right window does not have _NET_WM_STATE_HIDDEN set');
62 ###############################################################################
63 # Given two containers on different workspaces, when one is focused, then
64 # the other one does not have _NET_WM_STATE_HIDDEN set.
65 ###############################################################################
68 $windowA = open_window;
70 $windowB = open_window;
72 ok(!is_hidden($windowA), 'left window does not have _NET_WM_STATE_HIDDEN set');
73 ok(!is_hidden($windowB), 'right window does not have _NET_WM_STATE_HIDDEN set');
75 ###############################################################################
76 # Given two containers in the same tabbed container, when one is focused, then
77 # (only) the other one has _NET_WM_STATE_HIDDEN set.
78 # Given the other tab is focused, then the atom is transferred.
79 ###############################################################################
86 ok(is_hidden($tabA), 'unfocused tab has _NET_WM_STATE_HIDDEN set');
87 ok(!is_hidden($tabB), 'focused tab does not have _NET_WM_STATE_HIDDEN set');
91 ok(!is_hidden($tabA), 'focused tab does not have _NET_WM_STATE_HIDDEN set');
92 ok(is_hidden($tabB), 'unfocused tab has _NET_WM_STATE_HIDDEN set');
94 ###############################################################################
95 # Given three containers in the same stacked container, when the focused tab
96 # is moved to another workspace, then the now focused tab does not have
97 # _NET_WM_STATE_HIDDEN set anymore.
98 ###############################################################################
102 cmd 'layout stacked';
105 cmd 'move window to workspace unused';
107 ok(is_hidden($tabA), 'unfocused tab has _NET_WM_STATE_HIDDEN set');
108 ok(!is_hidden($tabB), 'focused tab does not have _NET_WM_STATE_HIDDEN set');
109 ok(!is_hidden($tabC), 'moved window does not have _NET_WM_STATE_HIDDEN set');
111 ###############################################################################
112 # Given three containers in the same stacked container, when a not focused
113 # tab is moved to another workspace, then it does not have _NET_WM_STATE_HIDDEN
115 ###############################################################################
119 cmd 'layout stacked';
123 cmd '[con_mark="moveme"] move window to workspace unused';
125 ok(is_hidden($tabA), 'unfocused tab has _NET_WM_STATE_HIDDEN set');
126 ok(!is_hidden($tabB), 'moved window does not have _NET_WM_STATE_HIDDEN set');
127 ok(!is_hidden($tabC), 'focused tab does not have _NET_WM_STATE_HIDDEN set');
129 ###############################################################################
130 # Given a tabbed container and some other container, when the latter is moved
131 # into the tabbed container, then all other tabs have _NET_WM_STATE_HIDDEN
133 ###############################################################################
144 ok(is_hidden($tabA), 'unfocused tab has _NET_WM_STATE_HIDDEN set');
145 ok(is_hidden($tabB), 'unfocused tab has _NET_WM_STATE_HIDDEN set');
146 ok(!is_hidden($tabC), 'focused tab does not have _NET_WM_STATE_HIDDEN set');
148 ###############################################################################
149 # Given a stacked container nested inside another tabbed container with the
150 # inner one being in the currently focused tab, then the focused tab of the
151 # inner container does not have _NET_WM_STATE_HIDDEN set.
152 ###############################################################################
161 cmd 'layout stacked';
162 $subtabA = open_window;
163 $subtabB = open_window;
165 ok(is_hidden($tabA), 'unfocused outer tab has _NET_WM_STATE_HIDDEN set');
166 ok(!is_hidden($tabB), 'focused outer tab does not have _NET_WM_STATE_HIDDEN set');
167 ok(is_hidden($subtabA), 'unfocused inner tab has _NET_WM_STATE_HIDDEN set');
168 ok(!is_hidden($subtabB), 'focused inner tab does not have _NET_WM_STATE_HIDDEN set');
172 ok(!is_hidden($subtabB), 'focused inner tab does not have _NET_WM_STATE_HIDDEN set');
174 ###############################################################################
175 # Given a stacked container nested inside another tabbed container with the
176 # inner one being in a currently not focused tab, then all tabs of the inner
177 # container have _NET_WM_STATE_HIDDEN set.
178 ###############################################################################
187 cmd 'layout stacked';
188 $subtabA = open_window;
189 $subtabB = open_window;
194 ok(!is_hidden($tabA), 'focused outer tab does not have _NET_WM_STATE_HIDDEN set');
195 ok(is_hidden($tabB), 'unfocused outer tab has _NET_WM_STATE_HIDDEN set');
196 ok(is_hidden($subtabA), 'unfocused inner tab has _NET_WM_STATE_HIDDEN set');
197 ok(is_hidden($subtabB), 'unfocused inner tab has _NET_WM_STATE_HIDDEN set');
199 ###############################################################################