i3 - improved tiling WM


Fix problem when moving fullscreen window to scratchpad

Patch status: superseded

Patch by jj

Long description:

When moving a fullscreen window to scratchpad with 'move scratchpad',
the focused window would stay fullscreen.

Also, when having a container in fullscreen mode and then focusing a child of
this container and moving it to scratchpad, it would enable fullscreen for
the child window.

This patch fixes both problems, so the scratchpad window is always
floating.

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

b/src/scratchpad.c

23
@@ -12,6 +12,20 @@
24
 #include "all.h"
25
 
26
 /*
27
+ * If the current con or any of its parents are in fullscreen mode, we
28
+ * first need to disable it before moving it to scratchpad.
29
+ *
30
+ */
31
+void disable_fullscreen(Con *con) {
32
+    while (con && con->fullscreen_mode == CF_NONE)
33
+        con = con->parent;
34
+
35
+    if (con->type != CT_WORKSPACE) {
36
+        con_toggle_fullscreen(con, CF_OUTPUT);
37
+    }
38
+}
39
+
40
+/*
41
  * Moves the specified window to the __i3_scratch workspace, making it floating
42
  * and setting the appropriate scratchpad_state.
43
  *
44
@@ -39,6 +53,8 @@ void scratchpad_move(Con *con) {
45
         return;
46
     }
47
 
48
+    disable_fullscreen(focused);
49
+
50
     /* 1: Ensure the window or any parent is floating. From now on, we deal
51
      * with the CT_FLOATING_CON. We use automatic == false because the user
52
      * made the choice that this window should be a scratchpad (and floating).
53
@@ -78,15 +94,7 @@ void scratchpad_show(Con *con) {
54
     Con *__i3_scratch = workspace_get("__i3_scratch", NULL);
55
     Con *floating;
56
 
57
-    /* If the current con or any of its parents are in fullscreen mode, we
58
-     * first need to disable it before showing the scratchpad con. */
59
-    Con *fs = focused;
60
-    while (fs && fs->fullscreen_mode == CF_NONE)
61
-        fs = fs->parent;
62
-
63
-    if (fs->type != CT_WORKSPACE) {
64
-        con_toggle_fullscreen(focused, CF_OUTPUT);
65
-    }
66
+    disable_fullscreen(focused);
67
 
68
     /* If this was 'scratchpad show' without criteria, we check if the
69
      * currently focused window is a scratchpad window and should be hidden