diff options
author | okan <okan> | 2011-03-22 13:50:40 +0000 |
---|---|---|
committer | okan <okan> | 2011-03-22 13:50:40 +0000 |
commit | 5972c7a507d37556b378b9490d56de296f9396e2 (patch) | |
tree | 47c2d714206b369e60ba4fdd0ab91866613be489 /menu.c | |
parent | e28a7f832e0cfa4e69a6018027f8c8cc27ca8eac (diff) | |
download | cwm-5972c7a507d37556b378b9490d56de296f9396e2.tar.gz cwm-5972c7a507d37556b378b9490d56de296f9396e2.tar.xz cwm-5972c7a507d37556b378b9490d56de296f9396e2.zip |
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 'menu.c')
-rw-r--r-- | menu.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/menu.c b/menu.c index 1771cc0..e757665 100644 --- a/menu.c +++ b/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); |