summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--grab.c9
-rw-r--r--kbfunc.c12
2 files changed, 13 insertions, 8 deletions
diff --git a/grab.c b/grab.c
index 6249c2b..eb3abd8 100644
--- a/grab.c
+++ b/grab.c
@@ -100,9 +100,14 @@ grab_sweep(struct client_ctx *cc)
 			XUnmapWindow(X_Dpy, sc->menuwin);
 			XReparentWindow(X_Dpy, sc->menuwin, sc->rootwin, 0, 0);
 			xu_ptr_ungrab();
-			cc->ptr.x = -1;
-			cc->ptr.y = -1;
+
+			/* Make sure the pointer stays within the window. */
+			if (cc->ptr.x > cc->geom.width)
+				cc->ptr.x = cc->geom.width - cc->bwidth;
+			if (cc->ptr.y > cc->geom.height)
+				cc->ptr.y = cc->geom.height - cc->bwidth;
 			client_ptrwarp(cc);
+
 			client_do_shape(cc);
 			return;
 		}
diff --git a/kbfunc.c b/kbfunc.c
index e006d34..f92efa1 100644
--- a/kbfunc.c
+++ b/kbfunc.c
@@ -89,12 +89,12 @@ kbfunc_moveresize(struct client_ctx *cc, void *arg)
 		cc->geom.width += mx;
 		client_resize(cc);
 
-		/*
-		 * Moving the cursor while resizing is problematic. Just place
-		 * it in the middle of the window.
-		 */
-		cc->ptr.x = -1;
-		cc->ptr.y = -1;
+		/* Make sure the pointer stays within the window. */
+		xu_ptr_getpos(cc->pwin, &cc->ptr.x, &cc->ptr.y);
+		if (cc->ptr.x > cc->geom.width)
+			cc->ptr.x = cc->geom.width - cc->bwidth;
+		if (cc->ptr.y > cc->geom.height)
+			cc->ptr.y = cc->geom.height - cc->bwidth;
 		client_ptrwarp(cc);
 		break;
 	case CWM_PTRMOVE: