Browse Source

attempt to grab the keyboard only 1000 times, not forever.

master 2.8
Anselm R. Garbe 18 years ago
parent
commit
f555908cef
  1. 2
      config.mk
  2. 16
      main.c

2
config.mk

@ -1,5 +1,5 @@
# dmenu version # dmenu version
VERSION = 2.7 VERSION = 2.8
# Customize below to fit your system # Customize below to fit your system

16
main.c

@ -108,12 +108,18 @@ drawmenu(void) {
XFlush(dpy); XFlush(dpy);
} }
static void static Bool
grabkeyboard(void) { grabkeyboard(void) {
while(XGrabKeyboard(dpy, root, True, GrabModeAsync, unsigned int len;
GrabModeAsync, CurrentTime) != GrabSuccess)
for(len = 1000; len; len--) {
if(XGrabKeyboard(dpy, root, True, GrabModeAsync, GrabModeAsync, CurrentTime)
== GrabSuccess)
break;
usleep(1000); usleep(1000);
} }
return len > 0;
}
static unsigned long static unsigned long
initcolor(const char *colstr) { initcolor(const char *colstr) {
@ -456,10 +462,10 @@ main(int argc, char *argv[]) {
root = RootWindow(dpy, screen); root = RootWindow(dpy, screen);
if(isatty(STDIN_FILENO)) { if(isatty(STDIN_FILENO)) {
maxname = readstdin(); maxname = readstdin();
grabkeyboard(); running = grabkeyboard();
} }
else { /* prevent keypress loss */ else { /* prevent keypress loss */
grabkeyboard(); running = grabkeyboard();
maxname = readstdin(); maxname = readstdin();
} }
/* init modifier map */ /* init modifier map */

Loading…
Cancel
Save