JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
made some changes more concistent
[dwm.git] / client.c
index 6a178f8..f3c9bf2 100644 (file)
--- a/client.c
+++ b/client.c
@@ -7,7 +7,7 @@
 #include <X11/Xatom.h>
 #include <X11/Xutil.h>
 
-/* static functions */
+/* static */
 
 static void
 detachstack(Client *c) {
@@ -53,12 +53,19 @@ grabbuttons(Client *c, Bool focused) {
                                GrabModeAsync, GrabModeSync, None, None);
 }
 
+static void
+setclientstate(Client *c, long state) {
+       long data[] = {state, None};
+       XChangeProperty(dpy, c->win, wmatom[WMState], wmatom[WMState], 32,
+                       PropModeReplace, (unsigned char *)data, 2);
+}
+
 static int
 xerrordummy(Display *dsply, XErrorEvent *ee) {
        return 0;
 }
 
-/* extern functions */
+/* extern */
 
 void
 configure(Client *c) {
@@ -169,6 +176,7 @@ manage(Window w, XWindowAttributes *wa) {
        stack = clients = c;
        XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
        XMapWindow(dpy, c->win);
+       setclientstate(c, NormalState);
        if(isvisible(c))
                focus(c);
        arrange();
@@ -178,6 +186,8 @@ void
 resize(Client *c, Bool sizehints) {
        XWindowChanges wc;
 
+       if(c->w <= 0 || c->h <= 0)
+               return;
        if(sizehints) {
                if(c->incw)
                        c->w -= (c->w - c->basew) % c->incw;
@@ -291,6 +301,7 @@ unmanage(Client *c) {
                focus(nc);
        }
        XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
+       setclientstate(c, WithdrawnState);
        free(c->tags);
        free(c);
        XSync(dpy, False);