i3 - improved tiling WM


bugfix: Resize and center a scratchpad even when a criteria is used.

Patch status: merged

Patch by Franck Michea

To apply this patch, use:
curl http://cr.i3wm.org/patch/189/raw.patch | git am

b/src/scratchpad.c

15
@@ -175,6 +175,10 @@ void scratchpad_show(Con *con) {
16
             LOG("Use 'move scratchpad' to move a window to the scratchpad.\n");
17
             return;
18
         }
19
+    } else {
20
+        /* We used a constraint, so we need to do what follows (moving,
21
+         * resizing) on the floating parent. */
22
+        con = con_inside_floating(con);
23
     }
24
 
25
     /* 1: Move the window from __i3_scratch to the current workspace. */

b/testcases/t/202-scratchpad-criteria.t

30
@@ -17,6 +17,8 @@
31
 # Verifies that using criteria to address scratchpad windows works.
32
 use i3test;
33
 
34
+my $i3 = i3(get_socket_path());
35
+
36
 #####################################################################
37
 # Verify that using scratchpad show with criteria works as expected:
38
 # - When matching a scratchpad window which is visible,
39
@@ -51,6 +53,22 @@ cmd '[title="scratch-match"] scratchpad show';
40
 my $scratch_focus = get_focused($tmp);
41
 isnt($scratch_focus, $old_focus, 'matching criteria works');
42
 
43
+# Check that the window was centered and resized too.
44
+my $tree = $i3->get_tree->recv;
45
+my $ws = get_ws($tmp);
46
+my $scratchrect = $ws->{floating_nodes}->[0]->{rect};
47
+my $output = $tree->{nodes}->[1];
48
+my $outputrect = $output->{rect};
49
+
50
+is($scratchrect->{width}, $outputrect->{width} * 0.5, 'scratch width is 50%');
51
+is($scratchrect->{height}, $outputrect->{height} * 0.75, 'scratch height is 75%');
52
+is($scratchrect->{x},
53
+   ($outputrect->{width} / 2) - ($scratchrect->{width} / 2),
54
+   'scratch window centered horizontally');
55
+is($scratchrect->{y},
56
+   ($outputrect->{height} / 2 ) - ($scratchrect->{height} / 2),
57
+   'scratch window centered vertically');
58
+
59
 cmd '[title="scratch-match"] scratchpad show';
60
 
61
 isnt(get_focused($tmp), $scratch_focus, 'matching criteria works');