i3 - improved tiling WM


Fix problem when moving fullscreen window to screen window to scratchpad

Patch status: needinfo

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/149/raw.patch | git am

b/src/scratchpad.c

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