X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=event.c;h=1a8de56b208373c5e94b7100278f5583c51c0d39;hb=95766d6241a401b3665ac1ad528b90c55e7b6810;hp=0f984f2fae13afa6127e9720145062055933d9db;hpb=b79b5facb104a653314577bb7f15824396b9e94b;p=dwm.git diff --git a/event.c b/event.c index 0f984f2..1a8de56 100644 --- 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