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 # 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_autostart => 0;
25 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
27 workspace 0 output fake-0
28 workspace 1 output fake-1
30 fake-outputs 1024x768+0+0,1024x768+1024+0
33 my $pid = launch_with_config($config);
35 sub get_desktop_viewport {
36 # Make sure that i3 pushed its changes to X11 before querying.
39 my $cookie = $x->get_property(
41 $x->get_root_window(),
42 $x->atom(name => '_NET_DESKTOP_VIEWPORT')->id,
43 $x->atom(name => 'CARDINAL')->id,
48 my $reply = $x->get_property_reply($cookie->{sequence});
50 return 0 if $reply->{value_len} == 0;
52 my $len = $reply->{length};
54 return unpack ("L$len", $reply->{value});
57 # initialize the workspaces
61 my @expected_viewport = (0, 0, 1024, 0);
62 my @desktop_viewport = get_desktop_viewport;
64 is_deeply(\@desktop_viewport, \@expected_viewport,
65 '_NET_DESKTOP_VIEWPORT should be an array of x/y coordinate pairs for the upper left corner of the respective outputs of the workspaces');
71 @expected_viewport = (0, 0, 0, 0, 1024, 0);
72 @desktop_viewport = get_desktop_viewport;
74 is_deeply(\@desktop_viewport, \@expected_viewport,
75 'it should be updated when a new workspace appears');
77 cmd 'rename workspace 3 to 2';
79 @expected_viewport = (0, 0, 0, 0, 1024, 0);
80 @desktop_viewport = get_desktop_viewport;
82 is_deeply(\@desktop_viewport, \@expected_viewport,
83 'it should stay up to date when a workspace is renamed');
87 @expected_viewport = (0, 0, 1024, 0);
88 @desktop_viewport = get_desktop_viewport;
90 is_deeply(\@desktop_viewport, \@expected_viewport,
91 'it should be updated when a workspace is emptied');
93 exit_gracefully($pid);