]> git.sur5r.net Git - i3/i3/blob - testcases/t/521-ewmh-desktop-viewport.t
Merge branch 'master' into next
[i3/i3] / testcases / t / 521-ewmh-desktop-viewport.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 # Test that the EWMH specified property _NET_DESKTOP_VIEWPORT is updated
18 # properly on the root window. We interpret this as a list of x/y coordinate
19 # pairs for the upper left corner of the respective outputs of the workspaces
20 # Ticket: #1241
21 use i3test i3_autostart => 0;
22
23 my $config = <<EOT;
24 # i3 config file (v4)
25 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
26
27 workspace 0 output fake-0
28 workspace 1 output fake-1
29
30 fake-outputs 1024x768+0+0,1024x768+1024+0
31 EOT
32
33 my $pid = launch_with_config($config);
34
35 sub get_desktop_viewport {
36     my $cookie = $x->get_property(
37         0,
38         $x->get_root_window(),
39         $x->atom(name => '_NET_DESKTOP_VIEWPORT')->id,
40         $x->atom(name => 'CARDINAL')->id,
41         0,
42         4096
43     );
44
45     my $reply = $x->get_property_reply($cookie->{sequence});
46
47     return 0 if $reply->{value_len} == 0;
48
49     my $len = $reply->{length};
50
51     return unpack ("L$len", $reply->{value});
52 }
53
54 # initialize the workspaces
55 cmd 'workspace 1';
56 cmd 'workspace 0';
57
58 my @expected_viewport = (0, 0, 1024, 0);
59 my @desktop_viewport = get_desktop_viewport;
60
61 is_deeply(\@desktop_viewport, \@expected_viewport,
62     '_NET_DESKTOP_VIEWPORT should be an array of x/y coordinate pairs for the upper left corner of the respective outputs of the workspaces');
63
64 cmd 'workspace 0';
65 open_window;
66 cmd 'workspace 3';
67
68 @expected_viewport = (0, 0, 0, 0, 1024, 0);
69 @desktop_viewport = get_desktop_viewport;
70
71 is_deeply(\@desktop_viewport, \@expected_viewport,
72     'it should be updated when a new workspace appears');
73
74 cmd 'rename workspace 3 to 2';
75
76 @expected_viewport = (0, 0, 0, 0, 1024, 0);
77 @desktop_viewport = get_desktop_viewport;
78
79 is_deeply(\@desktop_viewport, \@expected_viewport,
80     'it should stay up to date when a workspace is renamed');
81
82 cmd 'workspace 0';
83
84 @expected_viewport = (0, 0, 1024, 0);
85 @desktop_viewport = get_desktop_viewport;
86
87 is_deeply(\@desktop_viewport, \@expected_viewport,
88     'it should be updated when a workspace is emptied');
89
90 exit_gracefully($pid);
91
92 done_testing;