]> git.sur5r.net Git - i3/i3/blob - testcases/t/521-ewmh-desktop-viewport.t
tests: replace http:// with https:// where appropriate
[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 # • https://build.i3wm.org/docs/testsuite.html
6 #   (or docs/testsuite)
7 #
8 # • https://build.i3wm.org/docs/lib-i3test.html
9 #   (alternatively: perldoc ./testcases/lib/i3test.pm)
10 #
11 # • https://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_config => <<EOT;
22 # i3 config file (v4)
23 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
24
25 workspace 0 output fake-0
26 workspace 1 output fake-1
27
28 fake-outputs 1024x768+0+0,1024x768+1024+0
29 EOT
30
31 sub get_desktop_viewport {
32     # Make sure that i3 pushed its changes to X11 before querying.
33     sync_with_i3;
34
35     my $cookie = $x->get_property(
36         0,
37         $x->get_root_window(),
38         $x->atom(name => '_NET_DESKTOP_VIEWPORT')->id,
39         $x->atom(name => 'CARDINAL')->id,
40         0,
41         4096
42     );
43
44     my $reply = $x->get_property_reply($cookie->{sequence});
45
46     return 0 if $reply->{value_len} == 0;
47
48     my $len = $reply->{length};
49
50     return unpack ("L$len", $reply->{value});
51 }
52
53 # initialize the workspaces
54 cmd 'workspace 1';
55 cmd 'workspace 0';
56
57 my @expected_viewport = (0, 0, 1024, 0);
58 my @desktop_viewport = get_desktop_viewport;
59
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');
62
63 cmd 'workspace 0';
64 open_window;
65 cmd 'workspace 3';
66
67 @expected_viewport = (0, 0, 0, 0, 1024, 0);
68 @desktop_viewport = get_desktop_viewport;
69
70 is_deeply(\@desktop_viewport, \@expected_viewport,
71     'it should be updated when a new workspace appears');
72
73 cmd 'rename workspace 3 to 2';
74
75 @expected_viewport = (0, 0, 0, 0, 1024, 0);
76 @desktop_viewport = get_desktop_viewport;
77
78 is_deeply(\@desktop_viewport, \@expected_viewport,
79     'it should stay up to date when a workspace is renamed');
80
81 cmd 'workspace 0';
82
83 @expected_viewport = (0, 0, 1024, 0);
84 @desktop_viewport = get_desktop_viewport;
85
86 is_deeply(\@desktop_viewport, \@expected_viewport,
87     'it should be updated when a workspace is emptied');
88
89 done_testing;