attempt to grab the keyboard only 1000 times, not forever.
Anselm R. Garbe arg@suckless.org
Wed, 07 Mar 2007 11:01:14 +0100
M
main.c
→
main.c
@@ -108,11 +108,17 @@ XCopyArea(dpy, dc.drawable, win, dc.gc, 0, 0, mw, mh, 0, 0);
XFlush(dpy); } -static void +static Bool grabkeyboard(void) { - while(XGrabKeyboard(dpy, root, True, GrabModeAsync, - GrabModeAsync, CurrentTime) != GrabSuccess) + unsigned int len; + + for(len = 1000; len; len--) { + if(XGrabKeyboard(dpy, root, True, GrabModeAsync, GrabModeAsync, CurrentTime) + == GrabSuccess) + break; usleep(1000); + } + return len > 0; } static unsigned long@@ -456,10 +462,10 @@ screen = DefaultScreen(dpy);
root = RootWindow(dpy, screen); if(isatty(STDIN_FILENO)) { maxname = readstdin(); - grabkeyboard(); + running = grabkeyboard(); } else { /* prevent keypress loss */ - grabkeyboard(); + running = grabkeyboard(); maxname = readstdin(); } /* init modifier map */