JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
fix crash as described in FS#37
[spectrwm.git] / scrotwm.c
index 1a4dedb..a0d33b7 100644 (file)
--- a/scrotwm.c
+++ b/scrotwm.c
@@ -52,7 +52,7 @@
 
 static const char      *cvstag = "$scrotwm$";
 
-#define        SWM_VERSION     "0.9.26"
+#define        SWM_VERSION     "0.9.27"
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -1040,10 +1040,12 @@ custom_region(char *val)
        if (x  < 0 || x > DisplayWidth(display, sidx) ||
            y < 0 || y > DisplayHeight(display, sidx) ||
            w + x > DisplayWidth(display, sidx) ||
-           h + y > DisplayHeight(display, sidx))
-               errx(1, "region %ux%u+%u+%u not within screen boundaries "
+           h + y > DisplayHeight(display, sidx)) {
+               fprintf(stderr, "ignoring region %ux%u+%u+%u - not within screen boundaries "
                    "(%ux%u)\n", w, h, x, y,
                    DisplayWidth(display, sidx), DisplayHeight(display, sidx));
+               return;
+       }
 
        new_region(&screens[sidx], x, y, w, h);
 }
@@ -2832,6 +2834,9 @@ floating_toggle(struct swm_region *r, union arg *args)
        struct ws_win           *win = r->ws->focus;
        union arg               a;
 
+       if (win == NULL)
+               return;
+
        ewmh_update_win_state(win, ewmh[_NET_WM_STATE_ABOVE].atom,
            _NET_WM_STATE_TOGGLE);
 
@@ -4439,15 +4444,11 @@ unmanage_window(struct ws_win *win)
                        parent->child_trans = NULL;
        }
 
-       if (count_win(win->ws, 0) > 1) {
-               /* work around for mplayer going full screen */
-               if (!win->floating)
-                       focus_prev(win);
-       } else
-               /* the last window is getting nuked, so make sure
-                  the keyboard isn't left without focus */
-               XSetInputFocus(display, PointerRoot,
-                   PointerRoot, CurrentTime);
+       /* focus on root just in case */
+       XSetInputFocus(display, PointerRoot, PointerRoot, CurrentTime);
+
+       if (!win->floating)
+               focus_prev(win);
 
        TAILQ_REMOVE(&win->ws->winlist, win, entry);
        TAILQ_INSERT_TAIL(&win->ws->unmanagedlist, win, entry);