JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
Move some more declarations to where they belong.
[spectrwm.git] / scrotwm.c
index 029548f..51f73cf 100644 (file)
--- a/scrotwm.c
+++ b/scrotwm.c
@@ -48,7 +48,7 @@
  * DEALINGS IN THE SOFTWARE.
  */
 
-#define        SWM_VERSION     "0.5"
+#define        SWM_VERSION     "0.6"
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -1106,7 +1106,6 @@ cycle_layout(struct swm_region *r, union arg *args)
        if (ws->cur_layout->l_stack == NULL)
                ws->cur_layout = &layouts[0];
        ignore_enter = 1;
-
        stack();
 }
 
@@ -1758,6 +1757,8 @@ manage_window(Window id)
        unsigned char           ws_idx_str[SWM_PROPLEN], *prop = NULL;
        struct swm_region       *r;
        long                    mask;
+       int                     ws_idx;
+       const char              *errstr;
 
        if ((win = find_window(id)) != NULL)
                        return (win);   /* already being managed */
@@ -1774,9 +1775,6 @@ manage_window(Window id)
        r = root_to_region(win->wa.root);
        /* If the window was managed before, put it in the same workspace */
        if (prop) {
-               int             ws_idx;
-               const char      *errstr;
-
                DNPRINTF(SWM_D_PROP, "got property _SWM_WS=%s\n", prop);
                ws_idx = strtonum(prop, 0, 9, &errstr);
                if (errstr)
@@ -1930,16 +1928,16 @@ destroynotify(XEvent *e)
                        ws->focus = TAILQ_PREV(win, ws_win_list, entry);
                if (ws->focus == NULL)
                        ws->focus = TAILQ_FIRST(&ws->winlist);
-               if (ws->focus == win)
+               if (ws->focus == NULL || ws->focus == win) {
                        ws->focus = NULL;
-               if (cur_focus == win)
+                       unfocus_all();
+               } else
                        focus_win(ws->focus);
-
                TAILQ_REMOVE(&ws->winlist, win, entry);
                set_win_state(win, WithdrawnState);
                free(win);
+               stack();
        }
-       stack();
 }
 
 void