X-Git-Url: https://git.xinqibao.xyz/dwm.git/blobdiff_plain/d7734f996ff2eae29fea14af76711d7f51648c10..d2a4952956aa21a48ac40d7f650036682cb9d97d:/event.c?ds=inline

diff --git a/event.c b/event.c
index 42a6fc0..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,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;
 		}
@@ -136,7 +144,8 @@ buttonpress(XEvent *e) {
 		}
 		else if(ev->button == Button2)
 			zoom(NULL);
-		else if(ev->button == Button3 && (arrange == dofloat || c->isfloat)) {
+		else if(ev->button == Button3 && (arrange == dofloat || c->isfloat) &&
+				!c->isfixed) {
 			restack();
 			resizemouse(c);
 		}
@@ -235,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;
 
@@ -245,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;
 		}
 	}
@@ -346,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;