JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
stupid me, one needs to set c->{x,y,w,h} in configurerequest obviously ;)
[dwm.git] / event.c
diff --git a/event.c b/event.c
index 2e021d5..8a3d99a 100644 (file)
--- a/event.c
+++ b/event.c
@@ -82,7 +82,10 @@ resizemouse(Client *c) {
                switch(ev.type) {
                case ButtonRelease:
                        resize(c, True);
+                       XWarpPointer(dpy, None, c->win, 0, 0, 0, 0,
+                                       c->w + c->border - 1, c->h + c->border - 1);
                        XUngrabPointer(dpy, CurrentTime);
+                       while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
                        return;
                case ConfigureRequest:
                case Expose:
@@ -163,40 +166,25 @@ buttonpress(XEvent *e) {
 
 static void
 configurerequest(XEvent *e) {
-       unsigned long newmask;
        Client *c;
        XConfigureRequestEvent *ev = &e->xconfigurerequest;
        XWindowChanges wc;
 
        if((c = getclient(ev->window))) {
                c->ismax = False;
-               if(ev->value_mask & CWX)
-                       c->x = ev->x;
-               if(ev->value_mask & CWY)
-                       c->y = ev->y;
-               if(ev->value_mask & CWWidth)
-                       c->w = ev->width;
-               if(ev->value_mask & CWHeight)
-                       c->h = ev->height;
-               if(ev->value_mask & CWBorderWidth)
-                       c->border = ev->border_width;
-               wc.x = c->x;
-               wc.y = c->y;
-               wc.width = c->w;
-               wc.height = c->h;
-               newmask = ev->value_mask & (~(CWSibling | CWStackMode | CWBorderWidth));
-               if(newmask)
-                       XConfigureWindow(dpy, c->win, newmask, &wc);
-               else
+               c->border = (ev->value_mask & CWBorderWidth) ? ev->border_width : c->border;
+               if((!c->isfloat && (arrange != dofloat))
+                       || ((ev->value_mask & (CWX | CWY)) && !(ev->value_mask & (CWWidth | CWHeight))))
                        configure(c);
-               XSync(dpy, False);
-               if(c->isfloat) {
+               else {
+                       c->x = (ev->value_mask & CWX) ? ev->x : c->x;
+                       c->y = (ev->value_mask & CWY) ? ev->y : c->y;
+                       c->w = (ev->value_mask & CWWidth) ? ev->width : c->w;
+                       c->h = (ev->value_mask & CWHeight) ? ev->height : c->h;
                        resize(c, False);
                        if(!isvisible(c))
                                XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
                }
-               else
-                       arrange();
        }
        else {
                wc.x = ev->x;
@@ -207,8 +195,8 @@ configurerequest(XEvent *e) {
                wc.sibling = ev->above;
                wc.stack_mode = ev->detail;
                XConfigureWindow(dpy, ev->window, ev->value_mask, &wc);
-               XSync(dpy, False);
        }
+       XSync(dpy, False);
 }
 
 static void
@@ -230,7 +218,7 @@ enternotify(XEvent *e) {
        if((c = getclient(ev->window)) && isvisible(c))
                focus(c);
        else if(ev->window == root) {
-               issel = True;
+               selscreen = True;
                for(c = stack; c && !isvisible(c); c = c->snext);
                focus(c);
        }
@@ -269,8 +257,8 @@ leavenotify(XEvent *e) {
        XCrossingEvent *ev = &e->xcrossing;
 
        if((ev->window == root) && !ev->same_screen) {
-               issel = False;
-               focus(sel);
+               selscreen = False;
+               focus(NULL);
        }
 }
 
@@ -290,11 +278,8 @@ maprequest(XEvent *e) {
 
        if(!XGetWindowAttributes(dpy, ev->window, &wa))
                return;
-       if(wa.override_redirect) {
-               XSelectInput(dpy, ev->window,
-                               (StructureNotifyMask | PropertyChangeMask));
+       if(wa.override_redirect)
                return;
-       }
        if(!getclient(ev->window))
                manage(ev->window, &wa);
 }
@@ -308,10 +293,6 @@ propertynotify(XEvent *e) {
        if(ev->state == PropertyDelete)
                return; /* ignore */
        if((c = getclient(ev->window))) {
-               if(ev->atom == wmatom[WMProtocols]) {
-                       c->proto = getproto(c->win);
-                       return;
-               }
                switch (ev->atom) {
                        default: break;
                        case XA_WM_TRANSIENT_FOR: