X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=event.c;h=bc7d42c2a452097cf6e741c9e376374766af23d7;hb=4cb78a170c6daa488a90dffb60224fcf2b76fbf0;hp=c3169aa7001c3434f214028d6371c38985f048c4;hpb=92e55c7c53cb808b584982ac8f6d69112d713fab;p=dwm.git diff --git a/event.c b/event.c index c3169aa..bc7d42c 100644 --- a/event.c +++ b/event.c @@ -102,61 +102,39 @@ 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 && (arrange == dofloat || c->isfloat)) { - higher(c); + if(!c->ismax && (arrange == dofloat || c->isfloat)) movemouse(c); - } break; case Button2: - lower(c); + zoom(NULL); break; case Button3: - if(!c->ismax && (arrange == dofloat || c->isfloat)) { - higher(c); + if(!c->ismax && (arrange == dofloat || c->isfloat)) resizemouse(c); - } break; } } } -static void -clientmessage(XEvent *e) -{ - Client *c; - XClientMessageEvent *ev = &e->xclient; - - if(ev->message_type == netatom[NetActiveWindow]) { - if((c = getclient(ev->window)) && c->tags[tsel]) - focus(c); - } -} - static void configurerequest(XEvent *e) { @@ -235,13 +213,16 @@ enternotify(XEvent *e) Client *c; XCrossingEvent *ev = &e->xcrossing; - if(ev->detail == NotifyInferior) + if(ev->mode != NotifyNormal || ev->detail == NotifyInferior) return; 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 @@ -281,8 +262,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 @@ -351,7 +334,6 @@ unmapnotify(XEvent *e) void (*handler[LASTEvent]) (XEvent *) = { [ButtonPress] = buttonpress, - [ClientMessage] = clientmessage, [ConfigureRequest] = configurerequest, [DestroyNotify] = destroynotify, [EnterNotify] = enternotify,