On Wed, Oct 18, 2006 at 02:05:33PM +0200, Anselm R. Garbe wrote:
> I removed the busy grabbing loop from slock. I should readd it
> with attempting it 10 times at maximum with usleep(1000) in each
> iteration. Thanks for the hint.

hm... somehow like that?

diff -r f972e1e702f5 slock.c
--- a/slock.c   Mon Oct 16 17:06:45 2006 +0200
+++ b/slock.c   Wed Oct 18 19:05:49 2006 +0400
@@ -23,7 +23,7 @@ main(int argc, char **argv) {
         main(int argc, char **argv) {
                char curs[] = {0, 0, 0, 0, 0, 0, 0, 0};
        char buf[32], passwd[256];
-       int num, screen;
+       int num, screen, loop;
 #if HAVE_SHADOW_H
        struct spwd *sp;
 #else
@@ -75,11 +75,17 @@ 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;
+                       GrabModeAsync, GrabModeSync, None, invisible, 
CurrentTime) == GrabSuccess;
+
+       loop = 10;
+       while(--loop && XGrabKeyboard(dpy, RootWindow(dpy, screen), True, 
GrabModeAsync,
+                       GrabModeAsync, CurrentTime) != GrabSuccess)
+               usleep(1000);
+       running = running && (loop>0);
+
        XMapRaised(dpy, w);
        XSync(dpy, False);

Reply via email to