diff options
author | Anselm R. Garbe <arg@suckless.org> | 2007-03-07 11:01:14 +0100 |
---|---|---|
committer | Anselm R. Garbe <arg@suckless.org> | 2007-03-07 11:01:14 +0100 |
commit | f555908cef580106a50c53e096ec12bf4d2bb2e2 (patch) | |
tree | 229588d0805f9f1f6e24acfe99d70e62bd9736b2 /main.c | |
parent | 73120414e2e4a3a8031b243fb0d893506d4a0dc1 (diff) |
attempt to grab the keyboard only 1000 times, not forever.
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 16 |
1 files changed, 11 insertions, 5 deletions
@@ -108,11 +108,17 @@ drawmenu(void) { 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 @@ main(int argc, char *argv[]) { 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 */ |