]> git.sur5r.net Git - i3/i3/blob - testcases/t/204-regress-scratchpad-move.t
Merge branch 'fix-active'
[i3/i3] / testcases / t / 204-regress-scratchpad-move.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3 #
4 # Please read the following documents before working on tests:
5 # • http://build.i3wm.org/docs/testsuite.html
6 #   (or docs/testsuite)
7 #
8 # • http://build.i3wm.org/docs/lib-i3test.html
9 #   (alternatively: perldoc ./testcases/lib/i3test.pm)
10 #
11 # • http://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 # Moves the last window of a workspace to the scratchpad. The workspace will be
18 # cleaned up and previously, the subsequent focusing of a destroyed container
19 # would crash i3.
20 # Ticket: #913
21 # Bug still in: 4.4-97-gf767ac3
22 use i3test;
23 use X11::XCB qw(:all);
24
25 # TODO: move to X11::XCB
26 sub set_wm_class {
27     my ($id, $class, $instance) = @_;
28
29     # Add a _NET_WM_STRUT_PARTIAL hint
30     my $atomname = $x->atom(name => 'WM_CLASS');
31     my $atomtype = $x->atom(name => 'STRING');
32
33     $x->change_property(
34         PROP_MODE_REPLACE,
35         $id,
36         $atomname->id,
37         $atomtype->id,
38         8,
39         length($class) + length($instance) + 2,
40         "$instance\x00$class\x00"
41     );
42 }
43
44 sub open_special {
45     my %args = @_;
46     my $wm_class = delete($args{wm_class}) || 'special';
47
48     return open_window(
49         %args,
50         before_map => sub { set_wm_class($_->id, $wm_class, $wm_class) },
51     );
52 }
53
54 my $tmp = fresh_workspace;
55
56 # Open a new window which we can identify later on based on its WM_CLASS.
57 my $scratch = open_special;
58
59 my $tmp2 = fresh_workspace;
60
61 cmd '[class="special"] move scratchpad';
62
63 does_i3_live;
64
65 done_testing;