Re: [dwm] slock-0.2

From: Alex Elide <elide_AT_bk.ru>
Date: Wed, 18 Oct 2006 19:06:58 +0400

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);
Received on Wed Oct 18 2006 - 17:07:21 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 14:32:04 UTC