]> git.sur5r.net Git - i3/i3/blobdiff - src/scratchpad.c
Always auto center on 'scratchpad show' if window hasn't been repositioned by the...
[i3/i3] / src / scratchpad.c
index bf43d403cf03d432b8bc89a96842da06f3bad79b..a4d2950519619bd563f804c36854c666f6cfcbad 100644 (file)
@@ -89,10 +89,27 @@ void scratchpad_show(Con *con) {
     }
 
     /* If this was 'scratchpad show' without criteria, we check if there is a
-     * visible scratchpad window on another workspace. In this case we move it
-     * to the current workspace. */
+     * unfocused scratchpad on the current workspace and focus it */
     Con *walk_con;
     Con *focused_ws = con_get_workspace(focused);
+    TAILQ_FOREACH(walk_con, &(focused_ws->floating_head), floating_windows) {
+        if ((floating = con_inside_floating(walk_con)) &&
+            floating->scratchpad_state != SCRATCHPAD_NONE &&
+            floating != con_inside_floating(focused)) {
+                DLOG("Found an unfocused scratchpad window on this workspace\n");
+                DLOG("Focusing it: %p\n", walk_con);
+                /* use con_descend_tiling_focused to get the last focused
+                 * window inside this scratch container in order to
+                 * keep the focus the same within this container */
+                con_focus(con_descend_tiling_focused(walk_con));
+                return;
+            }
+    }
+
+    /* If this was 'scratchpad show' without criteria, we check if there is a
+     * visible scratchpad window on another workspace. In this case we move it
+     * to the current workspace. */
+    focused_ws = con_get_workspace(focused);
     TAILQ_FOREACH(walk_con, &all_cons, all_cons) {
         Con *walk_ws = con_get_workspace(walk_con);
         if (walk_ws &&
@@ -156,11 +173,11 @@ void scratchpad_show(Con *con) {
         Con *output = con_get_output(con);
         con->rect.width = output->rect.width * 0.5;
         con->rect.height = output->rect.height * 0.75;
+        floating_check_size(con);
         con->rect.x = output->rect.x +
                       ((output->rect.width / 2.0) - (con->rect.width / 2.0));
         con->rect.y = output->rect.y +
                       ((output->rect.height / 2.0) - (con->rect.height / 2.0));
-        con->scratchpad_state = SCRATCHPAD_CHANGED;
     }
 
     /* Activate active workspace if window is from another workspace to ensure