JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
renamed floating into swimming (this does not clash with C naming conventions and...
[dwm.git] / event.c
diff --git a/event.c b/event.c
index f06fb22..b8036fc 100644 (file)
--- a/event.c
+++ b/event.c
@@ -20,6 +20,14 @@ KEYS
 #define CLEANMASK(mask) (mask & ~(numlockmask | LockMask))
 #define MOUSEMASK              (BUTTONMASK | PointerMotionMask)
 
+static Client *
+getclient(Window w) {
+       Client *c;
+
+       for(c = clients; c && c->win != w; c = c->next);
+       return c;
+}
+
 static void
 movemouse(Client *c) {
        int x1, y1, ocx, ocy, di, nx, ny;
@@ -28,7 +36,7 @@ movemouse(Client *c) {
        XEvent ev;
 
        ocx = nx = c->x;
-       ocy = ny =  c->y;
+       ocy = ny = c->y;
        if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
                        None, cursor[CurMove], CurrentTime) != GrabSuccess)
                return;
@@ -129,10 +137,10 @@ buttonpress(XEvent *e) {
                                return;
                        }
                }
-               if(ev->x < x + bmw)
+               if(ev->x < x + blw)
                        switch(ev->button) {
                        case Button1:
-                               togglemode(NULL);
+                               togglelayout(NULL);
                                break;
                        case Button4:
                                a.i = 1;
@@ -148,14 +156,14 @@ buttonpress(XEvent *e) {
                focus(c);
                if(CLEANMASK(ev->state) != MODKEY)
                        return;
-               if(ev->button == Button1 && (arrange == dofloat || c->isfloat)) {
+               if(ev->button == Button1 && (lt->arrange == swim || c->swimming)) {
                        restack();
                        movemouse(c);
                }
                else if(ev->button == Button2)
                        zoom(NULL);
                else if(ev->button == Button3
-               && (arrange == dofloat || c->isfloat) && !c->isfixed)
+               && (lt->arrange == swim || c->swimming) && !c->isfixed)
                {
                        restack();
                        resizemouse(c);
@@ -173,7 +181,7 @@ configurerequest(XEvent *e) {
                c->ismax = False;
                if(ev->value_mask & CWBorderWidth)
                        c->border = ev->border_width;
-               if(c->isfixed || c->isfloat || (arrange == dofloat)) {
+               if(c->isfixed || c->swimming || (lt->arrange == swim)) {
                        if(ev->value_mask & CWX)
                                c->x = ev->x;
                        if(ev->value_mask & CWY)
@@ -185,9 +193,8 @@ configurerequest(XEvent *e) {
                        if((ev->value_mask & (CWX | CWY))
                        && !(ev->value_mask & (CWWidth | CWHeight)))
                                configure(c);
-                       resize(c, c->x, c->y, c->w, c->h, False);
-                       if(!isvisible(c))
-                               ban(c);
+                       if(isvisible(c))
+                               XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
                }
                else
                        configure(c);
@@ -302,8 +309,8 @@ propertynotify(XEvent *e) {
                        default: break;
                        case XA_WM_TRANSIENT_FOR:
                                XGetTransientForHint(dpy, c->win, &trans);
-                               if(!c->isfloat && (c->isfloat = (trans != 0)))
-                                       arrange();
+                               if(!c->swimming && (c->swimming = (getclient(trans) != NULL)))
+                                       lt->arrange();
                                break;
                        case XA_WM_NORMAL_HINTS:
                                updatesizehints(c);
@@ -361,14 +368,3 @@ grabkeys(void) {
                                GrabModeAsync, GrabModeAsync);
        }
 }
-
-void
-procevent(void) {
-       XEvent ev;
-
-       while(XPending(dpy)) {
-               XNextEvent(dpy, &ev);
-               if(handler[ev.type])
-                       (handler[ev.type])(&ev); /* call handler */
-       }
-}