2 # vim:ts=4:sw=4:expandtab
4 # Verifies that scratchpad windows show up on the proper output.
5 # ticket #596, bug present until up to commit
6 # 89dded044b4fffe78f9d70778748fabb7ac533e9.
8 use i3test i3_autostart => 0;
12 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
14 fake-outputs 1024x768+0+0,1024x768+1024+0
16 my $pid = launch_with_config($config);
18 my $i3 = i3(get_socket_path());
20 ################################################################################
21 # Open a workspace on the second output, put a window to scratchpad, display
22 # it, verify it’s on the same workspace.
23 ################################################################################
25 sub verify_scratchpad_on_same_ws {
28 is_num_children($ws, 0, 'no nodes on this ws');
30 my $window = open_window;
32 is_num_children($ws, 1, 'one nodes on this ws');
34 cmd 'move scratchpad';
36 is_num_children($ws, 0, 'no nodes on this ws');
38 cmd 'scratchpad show';
39 is_num_children($ws, 0, 'no nodes on this ws');
40 is(scalar @{get_ws($ws)->{floating_nodes}}, 1, 'one floating node on this ws');
43 my $second = fresh_workspace(output => 1);
45 verify_scratchpad_on_same_ws($second);
47 ################################################################################
48 # The same thing, but on the first output.
49 ################################################################################
51 my $first = fresh_workspace(output => 0);
53 verify_scratchpad_on_same_ws($first);
55 ################################################################################
56 # Now open the scratchpad on one output and switch to another.
57 ################################################################################
59 sub verify_scratchpad_switch {
60 my ($first, $second) = @_;
62 cmd "workspace $first";
64 is_num_children($first, 0, 'no nodes on this ws');
66 my $window = open_window;
68 is_num_children($first, 1, 'one nodes on this ws');
70 cmd 'move scratchpad';
72 is_num_children($first, 0, 'no nodes on this ws');
74 cmd "workspace $second";
76 cmd 'scratchpad show';
77 my $ws = get_ws($second);
78 is_num_children($second, 0, 'no nodes on this ws');
79 is(scalar @{$ws->{floating_nodes}}, 1, 'one floating node on this ws');
81 # Verify that the coordinates are within bounds.
82 my $srect = $ws->{floating_nodes}->[0]->{rect};
83 my $rect = $ws->{rect};
84 cmd 'nop before bounds check';
85 cmp_ok($srect->{x}, '>=', $rect->{x}, 'x within bounds');
86 cmp_ok($srect->{y}, '>=', $rect->{y}, 'y within bounds');
87 cmp_ok($srect->{x} + $srect->{width}, '<=', $rect->{x} + $rect->{width},
88 'width within bounds');
89 cmp_ok($srect->{y} + $srect->{height}, '<=', $rect->{y} + $rect->{height},
90 'height within bounds');
93 $first = fresh_workspace(output => 0);
94 $second = fresh_workspace(output => 1);
96 verify_scratchpad_switch($first, $second);
98 $first = fresh_workspace(output => 1);
99 $second = fresh_workspace(output => 0);
101 verify_scratchpad_switch($first, $second);
103 exit_gracefully($pid);