summaryrefslogtreecommitdiff
path: root/app/cwm
diff options
context:
space:
mode:
authorOkan Demirmen <okan@cvs.openbsd.org>2011-03-22 13:50:41 +0000
committerOkan Demirmen <okan@cvs.openbsd.org>2011-03-22 13:50:41 +0000
commit8d927e8cf1c6e01a73a57605ab8b6fae437fed01 (patch)
tree262a8db4da7b8a0e87f4dbaeb4836de7c8b68cf9 /app/cwm
parent756c4b34173f00fa461e930a17369101ea259552 (diff)
warp the pointer back, iff we don't move the mouse, once we are done
with the menu; idea and initial from Sviatoslav Chagaev. discussion with and ok oga@
Diffstat (limited to 'app/cwm')
-rw-r--r--app/cwm/menu.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/app/cwm/menu.c b/app/cwm/menu.c
index 1771cc040..e757665c3 100644
--- a/app/cwm/menu.c
+++ b/app/cwm/menu.c
@@ -97,6 +97,7 @@ menu_filter(struct screen_ctx *sc, struct menu_q *menuq, char *prompt,
XEvent e;
Window focuswin;
int evmask, focusrevert;
+ int xsave, ysave, xcur, ycur;
TAILQ_INIT(&resultq);
@@ -104,6 +105,9 @@ menu_filter(struct screen_ctx *sc, struct menu_q *menuq, char *prompt,
xu_ptr_getpos(sc->rootwin, &mc.x, &mc.y);
+ xsave = mc.x;
+ ysave = mc.y;
+
if (prompt == NULL) {
evmask = MenuMask;
mc.promptstr[0] = '\0';
@@ -177,6 +181,10 @@ out:
}
XSetInputFocus(X_Dpy, focuswin, focusrevert, CurrentTime);
+ /* restore if user didn't move */
+ xu_ptr_getpos(sc->rootwin, &xcur, &ycur);
+ if (xcur == mc.x && ycur == mc.y)
+ xu_ptr_setpos(sc->rootwin, xsave, ysave);
xu_ptr_ungrab();
XUnmapWindow(X_Dpy, sc->menuwin);