2 # vim:ts=4:sw=4:expandtab
4 # Please read the following documents before working on tests:
5 # • https://build.i3wm.org/docs/testsuite.html
8 # • https://build.i3wm.org/docs/lib-i3test.html
9 # (alternatively: perldoc ./testcases/lib/i3test.pm)
11 # • https://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 # 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
21 use i3test i3_config => <<EOT;
23 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
25 workspace 0 output fake-0
26 workspace 1 output fake-1
28 fake-outputs 1024x768+0+0,1024x768+1024+0
31 sub get_desktop_viewport {
32 # Make sure that i3 pushed its changes to X11 before querying.
35 my $cookie = $x->get_property(
37 $x->get_root_window(),
38 $x->atom(name => '_NET_DESKTOP_VIEWPORT')->id,
39 $x->atom(name => 'CARDINAL')->id,
44 my $reply = $x->get_property_reply($cookie->{sequence});
46 return 0 if $reply->{value_len} == 0;
48 my $len = $reply->{length};
50 return unpack ("L$len", $reply->{value});
53 # initialize the workspaces
57 my @expected_viewport = (0, 0, 1024, 0);
58 my @desktop_viewport = get_desktop_viewport;
60 is_deeply(\@desktop_viewport, \@expected_viewport,
61 '_NET_DESKTOP_VIEWPORT should be an array of x/y coordinate pairs for the upper left corner of the respective outputs of the workspaces');
67 @expected_viewport = (0, 0, 0, 0, 1024, 0);
68 @desktop_viewport = get_desktop_viewport;
70 is_deeply(\@desktop_viewport, \@expected_viewport,
71 'it should be updated when a new workspace appears');
73 cmd 'rename workspace 3 to 2';
75 @expected_viewport = (0, 0, 0, 0, 1024, 0);
76 @desktop_viewport = get_desktop_viewport;
78 is_deeply(\@desktop_viewport, \@expected_viewport,
79 'it should stay up to date when a workspace is renamed');
83 @expected_viewport = (0, 0, 1024, 0);
84 @desktop_viewport = get_desktop_viewport;
86 is_deeply(\@desktop_viewport, \@expected_viewport,
87 'it should be updated when a workspace is emptied');