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.
10 my $i3 = i3(get_socket_path());
12 ################################################################################
13 # Open a workspace on the second output, put a window to scratchpad, display
14 # it, verify it’s on the same workspace.
15 ################################################################################
17 sub verify_scratchpad_on_same_ws {
20 is(scalar @{get_ws($ws)->{nodes}}, 0, 'no nodes on this ws');
22 my $window = open_window;
24 is(scalar @{get_ws($ws)->{nodes}}, 1, 'one nodes on this ws');
26 cmd 'move scratchpad';
28 is(scalar @{get_ws($ws)->{nodes}}, 0, 'no nodes on this ws');
30 cmd 'scratchpad show';
31 is(scalar @{get_ws($ws)->{nodes}}, 0, 'no nodes on this ws');
32 is(scalar @{get_ws($ws)->{floating_nodes}}, 1, 'one floating node on this ws');
35 my $second = fresh_workspace(output => 1);
37 verify_scratchpad_on_same_ws($second);
39 ################################################################################
40 # The same thing, but on the first output.
41 ################################################################################
43 my $first = fresh_workspace(output => 0);
45 verify_scratchpad_on_same_ws($first);
47 ################################################################################
48 # Now open the scratchpad on one output and switch to another.
49 ################################################################################
51 sub verify_scratchpad_switch {
52 my ($first, $second) = @_;
54 cmd "workspace $first";
56 is(scalar @{get_ws($first)->{nodes}}, 0, 'no nodes on this ws');
58 my $window = open_window;
60 is(scalar @{get_ws($first)->{nodes}}, 1, 'one nodes on this ws');
62 cmd 'move scratchpad';
64 is(scalar @{get_ws($first)->{nodes}}, 0, 'no nodes on this ws');
66 cmd "workspace $second";
68 cmd 'scratchpad show';
69 my $ws = get_ws($second);
70 is(scalar @{$ws->{nodes}}, 0, 'no nodes on this ws');
71 is(scalar @{$ws->{floating_nodes}}, 1, 'one floating node on this ws');
73 # Verify that the coordinates are within bounds.
74 my $srect = $ws->{floating_nodes}->[0]->{rect};
75 my $rect = $ws->{rect};
76 cmd 'nop before bounds check';
77 cmp_ok($srect->{x}, '>=', $rect->{x}, 'x within bounds');
78 cmp_ok($srect->{y}, '>=', $rect->{y}, 'y within bounds');
79 cmp_ok($srect->{x} + $srect->{width}, '<=', $rect->{x} + $rect->{width},
80 'width within bounds');
81 cmp_ok($srect->{y} + $srect->{height}, '<=', $rect->{y} + $rect->{height},
82 'height within bounds');
85 $first = fresh_workspace(output => 0);
86 $second = fresh_workspace(output => 1);
88 verify_scratchpad_switch($first, $second);
90 $first = fresh_workspace(output => 1);
91 $second = fresh_workspace(output => 0);
93 verify_scratchpad_switch($first, $second);