]> git.sur5r.net Git - i3/i3/blob - testcases/t/211-regress-urgency-assign.t
Merge branch 'master' into next
[i3/i3] / testcases / t / 211-regress-urgency-assign.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 # Verifies that windows are properly recognized as urgent when they start up
18 # with the urgency hint already set (and are assigned to a non-visible
19 # workspace).
20 #
21 # Ticket: #1086
22 # Bug still in: 4.6-62-g7098ef6
23 use i3test i3_autostart => 0;
24 use X11::XCB qw(:all);
25
26 # TODO: move to X11::XCB
27 sub set_wm_class {
28     my ($id, $class, $instance) = @_;
29
30     # Add a _NET_WM_STRUT_PARTIAL hint
31     my $atomname = $x->atom(name => 'WM_CLASS');
32     my $atomtype = $x->atom(name => 'STRING');
33
34     $x->change_property(
35         PROP_MODE_REPLACE,
36         $id,
37         $atomname->id,
38         $atomtype->id,
39         8,
40         length($class) + length($instance) + 2,
41         "$instance\x00$class\x00"
42     );
43 }
44
45 sub open_special {
46     my %args = @_;
47     my $wm_class = delete($args{wm_class}) || 'special';
48     $args{name} //= 'special window';
49
50     # We use dont_map because i3 will not map the window on the current
51     # workspace. Thus, open_window would time out in wait_for_map (2 seconds).
52     my $window = open_window(
53         %args,
54         before_map => sub { set_wm_class($_->id, $wm_class, $wm_class) },
55         dont_map => 1,
56     );
57     $window->add_hint('urgency');
58     $window->map;
59     return $window;
60 }
61
62 my $config = <<EOT;
63 # i3 config file (v4)
64 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
65
66 assign [class="special"] nonvisible
67 EOT
68 my $pid = launch_with_config($config);
69
70 my $tmp = fresh_workspace;
71
72 ok((scalar grep { $_ eq 'nonvisible' } @{get_workspace_names()}) == 0,
73    'assignment destination workspace does not exist yet');
74
75 my $window = open_special;
76 sync_with_i3;
77
78 ok((scalar grep { $_ eq 'nonvisible' } @{get_workspace_names()}) > 0,
79    'assignment destination workspace exists');
80
81 my @urgent = grep { $_->{urgent} } @{get_ws_content('nonvisible')};
82 isnt(@urgent, 0, 'urgent window(s) found on destination workspace');
83
84 exit_gracefully($pid);
85
86 done_testing;