reverting keyboard grab to root window - invoking several dmenu's now works again...
This commit is contained in:
parent
9911455f5b
commit
73120414e2
46
main.c
46
main.c
@ -110,7 +110,7 @@ drawmenu(void) {
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
grabkeyboard(void) {
|
grabkeyboard(void) {
|
||||||
while(XGrabKeyboard(dpy, win, True, GrabModeAsync,
|
while(XGrabKeyboard(dpy, root, True, GrabModeAsync,
|
||||||
GrabModeAsync, CurrentTime) != GrabSuccess)
|
GrabModeAsync, CurrentTime) != GrabSuccess)
|
||||||
usleep(1000);
|
usleep(1000);
|
||||||
}
|
}
|
||||||
@ -454,6 +454,24 @@ main(int argc, char *argv[]) {
|
|||||||
eprint("dmenu: cannot open display\n");
|
eprint("dmenu: cannot open display\n");
|
||||||
screen = DefaultScreen(dpy);
|
screen = DefaultScreen(dpy);
|
||||||
root = RootWindow(dpy, screen);
|
root = RootWindow(dpy, screen);
|
||||||
|
if(isatty(STDIN_FILENO)) {
|
||||||
|
maxname = readstdin();
|
||||||
|
grabkeyboard();
|
||||||
|
}
|
||||||
|
else { /* prevent keypress loss */
|
||||||
|
grabkeyboard();
|
||||||
|
maxname = readstdin();
|
||||||
|
}
|
||||||
|
/* init modifier map */
|
||||||
|
modmap = XGetModifierMapping(dpy);
|
||||||
|
for (i = 0; i < 8; i++) {
|
||||||
|
for (j = 0; j < modmap->max_keypermod; j++) {
|
||||||
|
if(modmap->modifiermap[i * modmap->max_keypermod + j]
|
||||||
|
== XKeysymToKeycode(dpy, XK_Num_Lock))
|
||||||
|
numlockmask = (1 << i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
XFreeModifiermap(modmap);
|
||||||
/* style */
|
/* style */
|
||||||
dc.norm[ColBG] = initcolor(normbg);
|
dc.norm[ColBG] = initcolor(normbg);
|
||||||
dc.norm[ColFG] = initcolor(normfg);
|
dc.norm[ColFG] = initcolor(normfg);
|
||||||
@ -477,27 +495,6 @@ main(int argc, char *argv[]) {
|
|||||||
XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
|
XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
|
||||||
if(!dc.font.set)
|
if(!dc.font.set)
|
||||||
XSetFont(dpy, dc.gc, dc.font.xfont->fid);
|
XSetFont(dpy, dc.gc, dc.font.xfont->fid);
|
||||||
drawmenu();
|
|
||||||
XMapRaised(dpy, win);
|
|
||||||
XMaskEvent(dpy, ExposureMask, &ev);
|
|
||||||
drawmenu();
|
|
||||||
if(isatty(STDIN_FILENO)) {
|
|
||||||
maxname = readstdin();
|
|
||||||
grabkeyboard();
|
|
||||||
}
|
|
||||||
else { /* prevent keypress loss */
|
|
||||||
grabkeyboard();
|
|
||||||
maxname = readstdin();
|
|
||||||
}
|
|
||||||
/* init modifier map */
|
|
||||||
modmap = XGetModifierMapping(dpy);
|
|
||||||
for(i = 0; i < 8; i++)
|
|
||||||
for(j = 0; j < modmap->max_keypermod; j++) {
|
|
||||||
if(modmap->modifiermap[i * modmap->max_keypermod + j]
|
|
||||||
== XKeysymToKeycode(dpy, XK_Num_Lock))
|
|
||||||
numlockmask = (1 << i);
|
|
||||||
}
|
|
||||||
XFreeModifiermap(modmap);
|
|
||||||
if(maxname)
|
if(maxname)
|
||||||
cmdw = textw(maxname);
|
cmdw = textw(maxname);
|
||||||
if(cmdw > mw / 3)
|
if(cmdw > mw / 3)
|
||||||
@ -508,6 +505,7 @@ main(int argc, char *argv[]) {
|
|||||||
promptw = mw / 5;
|
promptw = mw / 5;
|
||||||
text[0] = 0;
|
text[0] = 0;
|
||||||
match(text);
|
match(text);
|
||||||
|
XMapRaised(dpy, win);
|
||||||
drawmenu();
|
drawmenu();
|
||||||
XSync(dpy, False);
|
XSync(dpy, False);
|
||||||
|
|
||||||
@ -519,6 +517,10 @@ main(int argc, char *argv[]) {
|
|||||||
case KeyPress:
|
case KeyPress:
|
||||||
kpress(&ev.xkey);
|
kpress(&ev.xkey);
|
||||||
break;
|
break;
|
||||||
|
case Expose:
|
||||||
|
if(ev.xexpose.count == 0)
|
||||||
|
drawmenu();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* cleanup */
|
/* cleanup */
|
||||||
|
Loading…
Reference in New Issue
Block a user