aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnselm R. Garbe <arg@suckless.org>2007-03-07 11:01:14 +0100
committerAnselm R. Garbe <arg@suckless.org>2007-03-07 11:01:14 +0100
commitf555908cef580106a50c53e096ec12bf4d2bb2e2 (patch)
tree229588d0805f9f1f6e24acfe99d70e62bd9736b2
parent73120414e2e4a3a8031b243fb0d893506d4a0dc1 (diff)
attempt to grab the keyboard only 1000 times, not forever.
-rw-r--r--config.mk2
-rw-r--r--main.c16
2 files changed, 12 insertions, 6 deletions
diff --git a/config.mk b/config.mk
index 07b323b..75cc46d 100644
--- a/config.mk
+++ b/config.mk
@@ -1,5 +1,5 @@
1# dmenu version 1# dmenu version
2VERSION = 2.7 2VERSION = 2.8
3 3
4# Customize below to fit your system 4# Customize below to fit your system
5 5
diff --git a/main.c b/main.c
index 0f07773..fa03ec8 100644
--- a/main.c
+++ b/main.c
@@ -108,11 +108,17 @@ drawmenu(void) {
108 XFlush(dpy); 108 XFlush(dpy);
109} 109}
110 110
111static void 111static Bool
112grabkeyboard(void) { 112grabkeyboard(void) {
113 while(XGrabKeyboard(dpy, root, True, GrabModeAsync, 113 unsigned int len;
114 GrabModeAsync, CurrentTime) != GrabSuccess) 114
115 for(len = 1000; len; len--) {
116 if(XGrabKeyboard(dpy, root, True, GrabModeAsync, GrabModeAsync, CurrentTime)
117 == GrabSuccess)
118 break;
115 usleep(1000); 119 usleep(1000);
120 }
121 return len > 0;
116} 122}
117 123
118static unsigned long 124static unsigned long
@@ -456,10 +462,10 @@ main(int argc, char *argv[]) {
456 root = RootWindow(dpy, screen); 462 root = RootWindow(dpy, screen);
457 if(isatty(STDIN_FILENO)) { 463 if(isatty(STDIN_FILENO)) {
458 maxname = readstdin(); 464 maxname = readstdin();
459 grabkeyboard(); 465 running = grabkeyboard();
460 } 466 }
461 else { /* prevent keypress loss */ 467 else { /* prevent keypress loss */
462 grabkeyboard(); 468 running = grabkeyboard();
463 maxname = readstdin(); 469 maxname = readstdin();
464 } 470 }
465 /* init modifier map */ 471 /* init modifier map */