]> git.sur5r.net Git - i3/i3/blob - testcases/t/190-scratchpad-diff-ws.t
Merge branch 'master' into next
[i3/i3] / testcases / t / 190-scratchpad-diff-ws.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 # Test for ticket #676: 'scratchpad show' causes a segfault if the scratchpad
18 # window is shown on another workspace.
19 #
20 use i3test;
21 use List::Util qw(first);
22 use X11::XCB qw(:all);
23
24 my $i3 = i3(get_socket_path());
25 my $tmp = fresh_workspace;
26
27 # TODO: move to X11::XCB
28 sub set_wm_class {
29     my ($id, $class, $instance) = @_;
30
31     # Add a _NET_WM_STRUT_PARTIAL hint
32     my $atomname = $x->atom(name => 'WM_CLASS');
33     my $atomtype = $x->atom(name => 'STRING');
34
35     $x->change_property(
36         PROP_MODE_REPLACE,
37         $id,
38         $atomname->id,
39         $atomtype->id,
40         8,
41         length($class) + length($instance) + 2,
42         "$instance\x00$class\x00"
43     );
44 }
45
46 sub open_special {
47     my %args = @_;
48     my $wm_class = delete($args{wm_class}) || 'special';
49
50     return open_window(
51         %args,
52         before_map => sub { set_wm_class($_->id, $wm_class, $wm_class) },
53     );
54 }
55
56 my $win = open_window;
57
58 my $scratch = open_special;
59 cmd '[class="special"] move scratchpad';
60
61 is_num_children($tmp, 1, 'one window on current ws');
62
63 my $otmp = fresh_workspace;
64 cmd 'scratchpad show';
65
66 cmd "workspace $tmp";
67 cmd '[class="special"] scratchpad show';
68
69 does_i3_live;
70
71 done_testing;