]> git.sur5r.net Git - i3/i3/blob - testcases/t/173-regress-focus-assign.t
Merge branch 'master' into next
[i3/i3] / testcases / t / 173-regress-focus-assign.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3 # !NO_I3_INSTANCE! will prevent complete-run.pl from starting i3
4 #
5 # Regression: Checks if focus is stolen when a window is managed which is
6 # assigned to an invisible workspace
7 #
8 use i3test;
9 use X11::XCB qw(PROP_MODE_REPLACE);
10
11 # TODO: move to X11::XCB
12 sub set_wm_class {
13     my ($id, $class, $instance) = @_;
14
15     # Add a _NET_WM_STRUT_PARTIAL hint
16     my $atomname = $x->atom(name => 'WM_CLASS');
17     my $atomtype = $x->atom(name => 'STRING');
18
19     $x->change_property(
20         PROP_MODE_REPLACE,
21         $id,
22         $atomname->id,
23         $atomtype->id,
24         8,
25         length($class) + length($instance) + 2,
26         "$instance\x00$class\x00"
27     );
28 }
29
30 sub open_special {
31     my %args = @_;
32     my $wm_class = delete($args{wm_class}) || 'special';
33     $args{name} //= 'special window';
34
35     return open_window(
36         %args,
37         before_map => sub { set_wm_class($_->id, $wm_class, $wm_class) },
38     );
39 }
40
41 #####################################################################
42 # start a window and see that it does not get assigned with an empty config
43 #####################################################################
44
45 my $config = <<EOT;
46 # i3 config file (v4)
47 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
48 assign "special" → targetws
49 EOT
50
51 my $pid = launch_with_config($config);
52
53 my $tmp = fresh_workspace;
54
55 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
56 ok(get_ws($tmp)->{focused}, 'current workspace focused');
57
58 my $window = open_special;
59
60 ok(@{get_ws_content($tmp)} == 0, 'special window not on current workspace');
61 ok(@{get_ws_content('targetws')} == 1, 'special window on targetws');
62 ok(get_ws($tmp)->{focused}, 'current workspace still focused');
63
64 #####################################################################
65 # the same test, but with a floating window
66 #####################################################################
67
68 $window = open_special(
69     window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_UTILITY'),
70 );
71
72 ok(@{get_ws_content($tmp)} == 0, 'special window not on current workspace');
73 ok(@{get_ws_content('targetws')} == 1, 'special window on targetws');
74 ok(get_ws($tmp)->{focused}, 'current workspace still focused');
75
76 exit_gracefully($pid);
77
78 $window->destroy;
79
80 done_testing;