]> git.sur5r.net Git - i3/i3/blob - testcases/t/505-scratchpad-resolution.t
Merge branch 'master' into next
[i3/i3] / testcases / t / 505-scratchpad-resolution.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3 #
4 # Verifies that scratchpad windows don’t move due to floating point caulcation
5 # errors when repeatedly hiding/showing, no matter what display resolution.
6 #
7 use i3test i3_autostart => 0;
8
9 my $config = <<EOT;
10 # i3 config file (v4)
11 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
12
13 fake-outputs 683x768+0+0,1024x768+683+0
14 EOT
15 my $pid = launch_with_config($config);
16
17 my $i3 = i3(get_socket_path());
18
19 $x->root->warp_pointer(0, 0);
20 sync_with_i3;
21
22 sub verify_scratchpad_doesnt_move {
23     my ($ws) = @_;
24
25     is(scalar @{get_ws($ws)->{nodes}}, 0, 'no nodes on this ws');
26
27     my $window = open_window;
28
29     is(scalar @{get_ws($ws)->{nodes}}, 1, 'one nodes on this ws');
30
31     cmd 'move scratchpad';
32
33     is(scalar @{get_ws($ws)->{nodes}}, 0, 'no nodes on this ws');
34
35     my $last_x = -1;
36     for (1 .. 20) {
37         cmd 'scratchpad show';
38         is(scalar @{get_ws($ws)->{floating_nodes}}, 1, 'one floating node on this ws');
39
40         # Verify that the coordinates are within bounds.
41         my $content = get_ws($ws);
42         my $srect = $content->{floating_nodes}->[0]->{rect};
43         if ($last_x > -1) {
44             is($srect->{x}, $last_x, 'scratchpad window did not move');
45         }
46         $last_x = $srect->{x};
47         cmd 'scratchpad show';
48     }
49
50     # We need to kill the scratchpad window, otherwise scratchpad show in
51     # subsequent calls of verify_scratchpad_doesnt_move will cycle between all
52     # the windows.
53     cmd 'scratchpad show';
54     cmd 'kill';
55 }
56
57 ################################################################################
58 # test it on the left output first (1366x768)
59 ################################################################################
60
61 my $second = fresh_workspace(output => 0);
62 verify_scratchpad_doesnt_move($second);
63
64 ################################################################################
65 # now on the right output (1024x768)
66 ################################################################################
67
68 $x->root->warp_pointer(683 + 10, 0);
69 sync_with_i3;
70
71 my $third = fresh_workspace(output => 1);
72 verify_scratchpad_doesnt_move($third);
73
74 exit_gracefully($pid);
75
76 done_testing;