]> 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_num_children($ws, 0, 'no nodes on this ws');
26
27     my $window = open_window;
28     is_num_children($ws, 1, 'one node on this ws');
29
30     cmd 'move scratchpad';
31     is_num_children($ws, 0, 'no nodes on this ws');
32
33     my $last_x = -1;
34     for (1 .. 20) {
35         cmd 'scratchpad show';
36         is(scalar @{get_ws($ws)->{floating_nodes}}, 1, 'one floating node on this ws');
37
38         # Verify that the coordinates are within bounds.
39         my $content = get_ws($ws);
40         my $srect = $content->{floating_nodes}->[0]->{rect};
41         if ($last_x > -1) {
42             is($srect->{x}, $last_x, 'scratchpad window did not move');
43         }
44         $last_x = $srect->{x};
45         cmd 'scratchpad show';
46     }
47
48     # We need to kill the scratchpad window, otherwise scratchpad show in
49     # subsequent calls of verify_scratchpad_doesnt_move will cycle between all
50     # the windows.
51     cmd 'scratchpad show';
52     cmd 'kill';
53 }
54
55 ################################################################################
56 # test it on the left output first (1366x768)
57 ################################################################################
58
59 my $second = fresh_workspace(output => 0);
60 verify_scratchpad_doesnt_move($second);
61
62 ################################################################################
63 # now on the right output (1024x768)
64 ################################################################################
65
66 $x->root->warp_pointer(683 + 10, 0);
67 sync_with_i3;
68
69 my $third = fresh_workspace(output => 1);
70 verify_scratchpad_doesnt_move($third);
71
72 exit_gracefully($pid);
73
74 done_testing;