]> git.sur5r.net Git - i3/i3/blob - testcases/t/505-scratchpad-resolution.t
Update ewmh focused only when new focus is different (#3496)
[i3/i3] / testcases / t / 505-scratchpad-resolution.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 # Verifies that scratchpad windows don’t move due to floating point caulcation
18 # errors when repeatedly hiding/showing, no matter what display resolution.
19 #
20 use i3test i3_config => <<EOT;
21 # i3 config file (v4)
22 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
23
24 fake-outputs 683x768+0+0,1024x768+683+0
25 EOT
26
27 sync_with_i3;
28 $x->root->warp_pointer(0, 0);
29 sync_with_i3;
30
31 sub verify_scratchpad_doesnt_move {
32     my ($ws) = @_;
33
34     is_num_children($ws, 0, 'no nodes on this ws');
35
36     my $window = open_window;
37     is_num_children($ws, 1, 'one node on this ws');
38
39     cmd 'move scratchpad';
40     is_num_children($ws, 0, 'no nodes on this ws');
41
42     my $last_x = -1;
43     for (1 .. 20) {
44         cmd 'scratchpad show';
45         is(scalar @{get_ws($ws)->{floating_nodes}}, 1, 'one floating node on this ws');
46
47         # Verify that the coordinates are within bounds.
48         my $content = get_ws($ws);
49         my $srect = $content->{floating_nodes}->[0]->{rect};
50         if ($last_x > -1) {
51             is($srect->{x}, $last_x, 'scratchpad window did not move');
52         }
53         $last_x = $srect->{x};
54         cmd 'scratchpad show';
55     }
56
57     # We need to kill the scratchpad window, otherwise scratchpad show in
58     # subsequent calls of verify_scratchpad_doesnt_move will cycle between all
59     # the windows.
60     cmd 'scratchpad show';
61     cmd 'kill';
62 }
63
64 ################################################################################
65 # test it on the left output first (1366x768)
66 ################################################################################
67
68 my $second = fresh_workspace(output => 0);
69 verify_scratchpad_doesnt_move($second);
70
71 ################################################################################
72 # now on the right output (1024x768)
73 ################################################################################
74
75 sync_with_i3;
76 $x->root->warp_pointer(683 + 10, 0);
77 sync_with_i3;
78
79 my $third = fresh_workspace(output => 1);
80 verify_scratchpad_doesnt_move($third);
81
82 done_testing;