X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=event.c;h=2deef143a55f2543ff71f6416a0ae0461bf74a2d;hb=177ed7e5de3e2c683d6457c7469c591cdbe6b999;hp=bf888195210a4e853b1ce74b73e3c39881872b5f;hpb=91e569ca37ac441930f041057d2934f02bf263a2;p=dwm.git diff --git a/event.c b/event.c index bf88819..2deef14 100644 --- a/event.c +++ b/event.c @@ -1,4 +1,4 @@ -/* (C)opyright MMVI Anselm R. Garbe +/* (C)opyright MMVI-MMVII Anselm R. Garbe * See LICENSE file for license details. */ #include "dwm.h" @@ -48,6 +48,14 @@ movemouse(Client *c) { XSync(dpy, False); c->x = ocx + (ev.xmotion.x - x1); c->y = ocy + (ev.xmotion.y - y1); + 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; } @@ -123,8 +131,20 @@ buttonpress(XEvent *e) { return; } } - if((ev->x < x + bmw) && (ev->button == Button1)) - togglemode(NULL); + if(ev->x < x + bmw) + switch(ev->button) { + case Button1: + togglemode(NULL); + break; + case Button4: + a.i = 1; + incnmaster(&a); + break; + case Button5: + a.i = -1; + incnmaster(&a); + break; + } } else if((c = getclient(ev->window))) { focus(c); @@ -153,7 +173,6 @@ configurerequest(XEvent *e) { if((c = getclient(ev->window))) { c->ismax = False; - gravitate(c, True); if(ev->value_mask & CWX) c->x = ev->x; if(ev->value_mask & CWY) @@ -164,7 +183,6 @@ configurerequest(XEvent *e) { c->h = ev->height; if(ev->value_mask & CWBorderWidth) c->border = ev->border_width; - gravitate(c, False); wc.x = c->x; wc.y = c->y; wc.width = c->w; @@ -230,13 +248,13 @@ expose(XEvent *e) { if(barwin == ev->window) drawstatus(); else if((c = getctitle(ev->window))) - drawtitle(c); + drawclient(c); } } static void keypress(XEvent *e) { - static unsigned int len = sizeof(key) / sizeof(key[0]); + static unsigned int len = sizeof key / sizeof key[0]; unsigned int i; KeySym keysym; XKeyEvent *ev = &e->xkey; @@ -248,7 +266,6 @@ keypress(XEvent *e) { { if(key[i].func) key[i].func(&key[i].arg); - return; } } } @@ -309,13 +326,13 @@ propertynotify(XEvent *e) { arrange(); break; case XA_WM_NORMAL_HINTS: - updatesize(c); + updatesizehints(c); break; } if(ev->atom == XA_WM_NAME || ev->atom == netatom[NetWMName]) { updatetitle(c); resizetitle(c); - drawtitle(c); + drawclient(c); } } } @@ -347,7 +364,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;