X-Git-Url: https://git.xinqibao.xyz/dwm.git/blobdiff_plain/91e569ca37ac441930f041057d2934f02bf263a2..7739e6b466481e66ad6b6fc8fb49fd884035431b:/event.c?ds=sidebyside

diff --git a/event.c b/event.c
index bf88819..4e11552 100644
--- a/event.c
+++ b/event.c
@@ -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;
 		}
@@ -236,7 +244,7 @@ expose(XEvent *e) {
 
 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 +256,6 @@ keypress(XEvent *e) {
 		{
 			if(key[i].func)
 				key[i].func(&key[i].arg);
-			return;
 		}
 	}
 }
@@ -347,7 +354,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;