changeset: 191:dd3d02b07cac
tag: tip
user: Anselm R. Garbe <arg_AT_suckless.org>
date: Wed Mar 07 11:01:14 2007 +0100
summary: attempt to grab the keyboard only 1000 times, not forever.
diff -r 37b511cb5733 -r dd3d02b07cac config.mk
--- a/config.mk Wed Mar 07 10:54:21 2007 +0100
+++ b/config.mk Wed Mar 07 11:01:14 2007 +0100
@@ -1,5 +1,5 @@
# dmenu version
-VERSION = 2.7
+VERSION = 2.8
# Customize below to fit your system
diff -r 37b511cb5733 -r dd3d02b07cac main.c
--- a/main.c Wed Mar 07 10:54:21 2007 +0100
+++ b/main.c Wed Mar 07 11:01:14 2007 +0100
@@ -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 */
Received on Wed Mar 07 2007 - 11:05:47 UTC
This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:56:14 UTC