]> git.sur5r.net Git - i3/i3/blob - testcases/t/190-scratchpad-diff-ws.t
Merge branch 'fix-fullscreen-scratch'
[i3/i3] / testcases / t / 190-scratchpad-diff-ws.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3 #
4 # Test for ticket #676: 'scratchpad show' causes a segfault if the scratchpad
5 # window is shown on another workspace.
6 #
7 use i3test;
8 use List::Util qw(first);
9 use X11::XCB qw(:all);
10
11 my $i3 = i3(get_socket_path());
12 my $tmp = fresh_workspace;
13
14 # TODO: move to X11::XCB
15 sub set_wm_class {
16     my ($id, $class, $instance) = @_;
17
18     # Add a _NET_WM_STRUT_PARTIAL hint
19     my $atomname = $x->atom(name => 'WM_CLASS');
20     my $atomtype = $x->atom(name => 'STRING');
21
22     $x->change_property(
23         PROP_MODE_REPLACE,
24         $id,
25         $atomname->id,
26         $atomtype->id,
27         8,
28         length($class) + length($instance) + 2,
29         "$instance\x00$class\x00"
30     );
31 }
32
33 sub open_special {
34     my %args = @_;
35     my $wm_class = delete($args{wm_class}) || 'special';
36
37     return open_window(
38         %args,
39         before_map => sub { set_wm_class($_->id, $wm_class, $wm_class) },
40     );
41 }
42
43 my $win = open_window;
44
45 my $scratch = open_special;
46 cmd '[class="special"] move scratchpad';
47
48 my ($nodes, $focus) = get_ws_content($tmp);
49 is(scalar @$nodes, 1, 'one window on current ws');
50
51 my $otmp = fresh_workspace;
52 cmd 'scratchpad show';
53
54 cmd "workspace $tmp";
55 cmd '[class="special"] scratchpad show';
56
57 does_i3_live;
58
59 done_testing;