2 # vim:ts=4:sw=4:expandtab
4 # Please read the following documents before working on tests:
5 # • http://build.i3wm.org/docs/testsuite.html
8 # • http://build.i3wm.org/docs/lib-i3test.html
9 # (alternatively: perldoc ./testcases/lib/i3test.pm)
11 # • http://build.i3wm.org/docs/ipc.html
14 # • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
15 # (unless you are already familiar with Perl)
17 # TODO: Description of this file.
19 # Bug still in: 4.13-12-g2ff3d9d
20 use File::Temp qw(tempfile);
21 use i3test i3_autostart => 0;
25 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
29 my ($outfh, $outname) = tempfile('i3-randr15reply-XXXXXX', UNLINK => 1);
31 # Prepare a RRGetMonitors reply, see A.2.4 in
32 # https://cgit.freedesktop.org/xorg/proto/randrproto/tree/randrproto.txt
33 my $reply = pack('cxSLLLLx[LLL]',
35 0, # sequence (will be filled in by inject_randr15)
36 # 56 = length($reply) + length($monitor1)
37 # 32 = minimum X11 reply length
38 (56-32) / 4, # length in words
43 # Manually intern _NET_CURRENT_DESKTOP as $x->atom will not create atoms if
44 # they are not yet interned.
45 my $atom_cookie = $x->intern_atom(0, length("DP3"), "DP3");
46 my $DP3 = $x->intern_atom_reply($atom_cookie->{sequence})->{atom};
48 # MONITORINFO is defined in A.1.1 in
49 # https://cgit.freedesktop.org/xorg/proto/randrproto/tree/randrproto.txt
50 my $monitor1 = pack('LccSssSSLL',
57 3840, # width in pixels
58 2160, # height in pixels
59 520, # width in millimeters
60 290); # height in millimeters
63 print $outfh $monitor1;
67 my $pid = launch_with_config($config, inject_randr15 => $outname);
69 my $tree = i3->get_tree->recv;
70 my @outputs = map { $_->{name} } @{$tree->{nodes}};
71 is_deeply(\@outputs, [ '__i3', 'DP3' ], 'outputs are __i3 and DP3');
73 my ($dp3) = grep { $_->{name} eq 'DP3' } @{$tree->{nodes}};
74 is_deeply($dp3->{rect}, {
79 }, 'Output DP3 at 3840x2160+0+0');
81 exit_gracefully($pid);
83 ################################################################################
84 # Verify that adding monitors with RandR 1.5 results in i3 outputs.
85 ################################################################################
87 # When inject_randr15 is defined but false, fake-xinerama will be turned off,
88 # but inject_randr15 will not actually be used.
89 my $pid = launch_with_config($config, inject_randr15 => '');
91 $tree = i3->get_tree->recv;
92 @outputs = map { $_->{name} } @{$tree->{nodes}};
93 is_deeply(\@outputs, [ '__i3', 'default' ], 'outputs are __i3 and default');
96 skip 'xrandr --setmonitor failed (xrandr too old?)', 1 unless
97 system(q|xrandr --setmonitor up2414q 3840/527x2160/296+1280+0 none|) == 0;
101 $tree = i3->get_tree->recv;
102 @outputs = map { $_->{name} } @{$tree->{nodes}};
103 is_deeply(\@outputs, [ '__i3', 'default', 'up2414q' ], 'outputs are __i3, default and up2414q');
106 exit_gracefully($pid);