JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
new resize stuff (using XConfigureWindow instead of XSendEvent)
[dwm.git] / client.c
index 7bc6772..f90a182 100644 (file)
--- a/client.c
+++ b/client.c
@@ -191,7 +191,7 @@ killclient(Arg *arg)
 {
        if(!sel)
                return;
-       if(sel->proto & WM_PROTOCOL_DELWIN)
+       if(sel->proto & PROTODELWIN)
                sendevent(sel->win, wmatom[WMProtocols], wmatom[WMDelete]);
        else
                XKillClient(dpy, sel->win);
@@ -271,7 +271,7 @@ resize(Client *c, Bool sizehints, Corner sticky)
 {
        int bottom = c->y + c->h;
        int right = c->x + c->w;
-       XConfigureEvent e;
+       XWindowChanges wc;
 
        if(sizehints) {
                if(c->incw)
@@ -287,30 +287,22 @@ resize(Client *c, Bool sizehints, Corner sticky)
                if(c->maxh && c->h > c->maxh)
                        c->h = c->maxh;
        }
-       if(c->x > sw) /* might happen on restart */
-               c->x = sw - c->w;
-       if(c->y > sh)
-               c->y = sh - c->h;
        if(sticky == TopRight || sticky == BotRight)
                c->x = right - c->w;
        if(sticky == BotLeft || sticky == BotRight)
                c->y = bottom - c->h;
 
        resizetitle(c);
-       XSetWindowBorderWidth(dpy, c->win, 1);
-       XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
-
-       e.type = ConfigureNotify;
-       e.event = c->win;
-       e.window = c->win;
-       e.x = c->x;
-       e.y = c->y;
-       e.width = c->w;
-       e.height = c->h;
-       e.border_width = c->border;
-       e.above = None;
-       e.override_redirect = False;
-       XSendEvent(dpy, c->win, False, StructureNotifyMask, (XEvent *)&e);
+
+       if(c->tags[tsel])
+               wc.x = c->x;
+       else
+               wc.x = c->x + 2 * sw;
+       wc.y = c->y;
+       wc.width = c->w;
+       wc.height = c->h;
+       wc.border_width = 1;
+       XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
        XSync(dpy, False);
 }
 
@@ -416,20 +408,18 @@ togglemax(Arg *arg)
 void
 unmanage(Client *c)
 {
-       Client **l;
-
        XGrabServer(dpy);
        XSetErrorHandler(xerrordummy);
 
        XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
        XDestroyWindow(dpy, c->title);
 
-       for(l = &clients; *l && *l != c; l = &(*l)->next);
        if(c->prev)
                c->prev->next = c->next;
        if(c->next)
                c->next->prev = c->prev;
-       *l = c->next;
+       if(c == clients)
+               clients = c->next;
        if(sel == c) {
                sel = getnext(c->next);
                if(!sel)
@@ -450,7 +440,7 @@ unmanage(Client *c)
 void
 zoom(Arg *arg)
 {
-       Client *c, **l;
+       Client *c;
 
        if(!sel)
                return;
@@ -461,13 +451,10 @@ zoom(Arg *arg)
        }
 
        /* pop */
-       for(l = &clients; *l && *l != sel; l = &(*l)->next);
        if(sel->prev)
                sel->prev->next = sel->next;
        if(sel->next)
                sel->next->prev = sel->prev;
-       *l = sel->next;
-
        sel->prev = NULL;
        if(clients)
                clients->prev = sel;