X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=event.c;h=45a21a661b76fc9f208a134ac9f8406e3b7395b4;hb=19390b1a91da680a502ce5acebd086cfbe32627c;hp=e3bdea42fa30f6a9b564d3ac08dc43ea288adf46;hpb=04b633ddf394fccf5a3125ea17239bad6997c8df;p=dwm.git diff --git a/event.c b/event.c index e3bdea4..45a21a6 100644 --- a/event.c +++ b/event.c @@ -11,7 +11,7 @@ typedef struct { unsigned long mod; KeySym keysym; - void (*func)(Arg *arg); + void (*func[NFUNCS])(Arg *arg); Arg arg; } Key; @@ -48,14 +48,14 @@ movemouse(Client *c) { XSync(dpy, False); c->x = ocx + (ev.xmotion.x - x1); c->y = ocy + (ev.xmotion.y - y1); - if(abs(sx + c->x) < SNAP) - c->x = sx; - else if(abs((sx + sw) - (c->x + c->w)) < SNAP) - c->x = sw - c->w - 2 * BORDERPX; - if(abs((sy + bh) - c->y) < SNAP) - c->y = sy + bh; - else if(abs((sy + sh) - (c->y + c->h)) < SNAP) - c->y = sh - c->h - 2 * BORDERPX; + if(abs(wax + c->x) < SNAP) + c->x = wax; + else if(abs((wax + waw) - (c->x + c->w)) < SNAP) + c->x = wax + waw - c->w - 2 * BORDERPX; + if(abs(way - c->y) < SNAP) + c->y = way; + else if(abs((way + wah) - (c->y + c->h)) < SNAP) + c->y = way + wah - c->h - 2 * BORDERPX; resize(c, False, TopLeft); break; } @@ -244,8 +244,8 @@ expose(XEvent *e) { static void keypress(XEvent *e) { - static unsigned int len = sizeof(key) / sizeof(key[0]); - unsigned int i; + static unsigned int len = sizeof key / sizeof key[0]; + unsigned int i, j; KeySym keysym; XKeyEvent *ev = &e->xkey; @@ -254,8 +254,9 @@ keypress(XEvent *e) { if(keysym == key[i].keysym && CLEANMASK(key[i].mod) == CLEANMASK(ev->state)) { - if(key[i].func) - key[i].func(&key[i].arg); + for(j = 0; j < NFUNCS; j++) + if(key[i].func[j]) + key[i].func[j](&key[i].arg); return; } } @@ -355,7 +356,7 @@ void (*handler[LASTEvent]) (XEvent *) = { void grabkeys(void) { - static unsigned int len = sizeof(key) / sizeof(key[0]); + static unsigned int len = sizeof key / sizeof key[0]; unsigned int i; KeyCode code;