From 10ccc43597910428a22129cd942881835d95b5c0 Mon Sep 17 00:00:00 2001 From: "Anselm R. Garbe" Date: Mon, 16 Oct 2006 12:59:37 +0200 Subject: added pointer grab --- slock.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'slock.c') diff --git a/slock.c b/slock.c index 0f4c3cc..72afd1e 100644 --- a/slock.c +++ b/slock.c @@ -63,9 +63,6 @@ main(int argc, char **argv) { /* init */ passwd[0] = 0; - while(XGrabKeyboard(dpy, RootWindow(dpy, screen), True, GrabModeAsync, - GrabModeAsync, CurrentTime) != GrabSuccess) - usleep(1000); wa.override_redirect = 1; wa.background_pixel = BlackPixel(dpy, screen); @@ -78,6 +75,11 @@ main(int argc, char **argv) { pmap = XCreateBitmapFromData(dpy, w, curs, 8, 8); invisible = XCreatePixmapCursor(dpy, pmap, pmap, &black, &black, 0, 0); XDefineCursor(dpy, w, invisible); + running = XGrabPointer(dpy, RootWindow(dpy, screen), False, + ButtonPressMask | ButtonReleaseMask | PointerMotionMask, + GrabModeAsync, GrabModeSync, None, invisible, CurrentTime) == GrabSuccess + && XGrabKeyboard(dpy, RootWindow(dpy, screen), True, GrabModeAsync, + GrabModeAsync, CurrentTime) == GrabSuccess; XMapRaised(dpy, w); XSync(dpy, False); @@ -119,6 +121,7 @@ main(int argc, char **argv) { break; } } + XUngrabPointer(dpy, CurrentTime); XFreePixmap(dpy, pmap); XDestroyWindow(dpy, w); XCloseDisplay(dpy); -- cgit v1.2.3-70-g09d2