X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=event.c;h=3086284bd576d189b3466e0884fe2dae30bb7b02;hb=52f0b9e2e3e7eba1e7d2b940863d9a72fa8112d6;hp=fbce6315e926029507c634c2116effdebe992b2c;hpb=3167373512c562f8f040203d2ee29084c76d00a0;p=dwm.git diff --git a/event.c b/event.c index fbce631..3086284 100644 --- 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; @@ -129,10 +137,11 @@ buttonpress(XEvent *e) { return; } } - if(ev->x < x + bmw) + if(ev->x < x + blw) switch(ev->button) { case Button1: - togglemode(NULL); + a.i = -1; + setlayout(&a); break; case Button4: a.i = 1; @@ -148,14 +157,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 == versatile || c->isversatile)) { restack(); movemouse(c); } else if(ev->button == Button2) zoom(NULL); else if(ev->button == Button3 - && (arrange == dofloat || c->isfloat) && !c->isfixed) + && (lt->arrange == versatile || c->isversatile) && !c->isfixed) { restack(); resizemouse(c); @@ -165,7 +174,6 @@ buttonpress(XEvent *e) { static void configurerequest(XEvent *e) { - int x, y, w, h; Client *c; XConfigureRequestEvent *ev = &e->xconfigurerequest; XWindowChanges wc; @@ -174,25 +182,20 @@ configurerequest(XEvent *e) { c->ismax = False; if(ev->value_mask & CWBorderWidth) c->border = ev->border_width; - if(c->isfixed || c->isfloat || (arrange == dofloat)) { - x = (ev->value_mask & CWX) ? ev->x : c->x; - y = (ev->value_mask & CWY) ? ev->y : c->y; - w = (ev->value_mask & CWWidth) ? ev->width : c->w; - h = (ev->value_mask & CWHeight) ? ev->height : c->h; + if(c->isfixed || c->isversatile || (lt->arrange == versatile)) { + 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 & (CWX | CWY)) && !(ev->value_mask & (CWWidth | CWHeight))) - { - c->x = x; - c->y = y; configure(c); - if(isvisible(c)) - XMoveWindow(dpy, c->win, c->x, c->y); - } - else { - resize(c, x, y, w, 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); @@ -307,8 +310,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->isversatile && (c->isversatile = (getclient(trans) != NULL))) + lt->arrange(); break; case XA_WM_NORMAL_HINTS: updatesizehints(c); @@ -366,14 +369,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 */ - } -}