JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
applied Sanders LD and resize patches
[dwm.git] / event.c
diff --git a/event.c b/event.c
index 0f984f2..1a8de56 100644 (file)
--- a/event.c
+++ b/event.c
@@ -58,6 +58,7 @@ static void
 resizemouse(Client *c)
 {
        int ocx, ocy;
+       int nw, nh;
        Corner sticky;
        XEvent ev;
 
@@ -76,8 +77,10 @@ resizemouse(Client *c)
                        break;
                case MotionNotify:
                        XSync(dpy, False);
-                       c->w = abs(ocx - ev.xmotion.x);
-                       c->h = abs(ocy - ev.xmotion.y);
+                       if((nw = abs(ocx - ev.xmotion.x)))
+                               c->w = abs(ocx - ev.xmotion.x);
+                       if((nh = abs(ocy - ev.xmotion.y)))
+                               c->h = abs(ocy - ev.xmotion.y);
                        c->x = (ocx <= ev.xmotion.x) ? ocx : ocx - c->w;
                        c->y = (ocy <= ev.xmotion.y) ? ocy : ocy - c->h;
                        if(ocx <= ev.xmotion.x)
@@ -102,45 +105,34 @@ buttonpress(XEvent *e)
        XButtonPressedEvent *ev = &e->xbutton;
 
        if(barwin == ev->window) {
-               switch(ev->button) {
-               default:
-                       x = 0;
-                       for(a.i = 0; a.i < ntags; a.i++) {
-                               x += textw(tags[a.i]);
-                               if(ev->x < x) {
+               x = 0;
+               for(a.i = 0; a.i < ntags; a.i++) {
+                       x += textw(tags[a.i]);
+                       if(ev->x < x) {
+                               if(ev->button == Button3)
+                                       toggleview(&a);
+                               else
                                        view(&a);
-                                       break;
-                               }
+                               return;
                        }
-                       break;
-               case Button4:
-                       viewnext(&a);
-                       break;
-               case Button5:
-                       viewprev(&a);
-                       break;
                }
        }
        else if((c = getclient(ev->window))) {
+               higher(c);
                focus(c);
                switch(ev->button) {
                default:
                        break;
                case Button1:
-                       if(!c->ismax) {
-                               if(arrange == dofloat || c->isfloat) {
-                                       higher(c);
-                                       movemouse(c);
-                               }
-                               else
-                                       zoom(NULL);
-                       }
+                       if(!c->ismax && (arrange == dofloat || c->isfloat))
+                               movemouse(c);
+                       break;
+               case Button2:
+                       zoom(NULL);
                        break;
                case Button3:
-                       if(!c->ismax && (arrange == dofloat || c->isfloat)) {
-                               higher(c);
+                       if(!c->ismax && (arrange == dofloat || c->isfloat))
                                resizemouse(c);
-                       }
                        break;
                }
        }
@@ -229,8 +221,11 @@ enternotify(XEvent *e)
 
        if((c = getclient(ev->window)) || (c = getctitle(ev->window)))
                focus(c);
-       else if(ev->window == root)
+       else if(ev->window == root) {
                issel = True;
+               XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
+               drawall();
+       }
 }
 
 static void
@@ -270,8 +265,10 @@ leavenotify(XEvent *e)
 {
        XCrossingEvent *ev = &e->xcrossing;
 
-       if((ev->window == root) && !ev->same_screen)
-               issel = True;
+       if((ev->window == root) && !ev->same_screen) {
+               issel = False;
+               drawall();
+       }
 }
 
 static void