]> git.sur5r.net Git - i3/i3/blob - testcases/t/208-regress-floating-criteria.t
Merge branch 'master' into next
[i3/i3] / testcases / t / 208-regress-floating-criteria.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 # Regression test for focus handling when using floating enable/disable with
18 # criteria for windows on non-visible workspaces.
19 # Ticket: #1027
20 # Bug still in: 4.5.1-90-g6582da9
21 use i3test i3_autostart => 0;
22 use X11::XCB qw(PROP_MODE_REPLACE);
23
24 my $config = <<'EOT';
25 # i3 config file (v4)
26 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
27
28 assign [class="^special$"] → mail
29 for_window [class="^special$"] floating enable, floating disable
30 EOT
31
32 my $pid = launch_with_config($config);
33
34 # TODO: move this to X11::XCB::Window
35 sub set_wm_class {
36     my ($id, $class, $instance) = @_;
37
38     # Add a _NET_WM_STRUT_PARTIAL hint
39     my $atomname = $x->atom(name => 'WM_CLASS');
40     my $atomtype = $x->atom(name => 'STRING');
41
42     $x->change_property(
43         PROP_MODE_REPLACE,
44         $id,
45         $atomname->id,
46         $atomtype->id,
47         8,
48         length($class) + length($instance) + 2,
49         "$instance\x00$class\x00"
50     );
51 }
52
53 my $window = open_window(
54     name => 'Borderless window',
55     before_map => sub { set_wm_class($_->id, 'special', 'special') },
56     dont_map => 1,
57 );
58 $window->map;
59
60 sync_with_i3;
61
62 cmd '[class="^special$"] focus';
63
64 does_i3_live;
65
66 exit_gracefully($pid);
67
68 done_testing;