summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorAnselm R. Garbe <arg@suckless.org>2007-03-02 21:48:48 +0100
committerAnselm R. Garbe <arg@suckless.org>2007-03-02 21:48:48 +0100
commitd57c873f104cb8be34299efe70e02df4bf275d92 (patch)
tree6c22f2f711c85f5641f879e9da83e67a9eeda694 /main.c
parent724f72142f6dc880068a92e412f3f3366e643569 (diff)
keyboard grab works on the dmenu window now (not on the root window) - thx for Kris for this hint
Diffstat (limited to 'main.c')
-rw-r--r--main.c41
1 files changed, 20 insertions, 21 deletions
diff --git a/main.c b/main.c
index 0f07773..beb8411 100644
--- a/main.c
+++ b/main.c
@@ -110,7 +110,7 @@ drawmenu(void) {
static void
grabkeyboard(void) {
- while(XGrabKeyboard(dpy, root, True, GrabModeAsync,
+ while(XGrabKeyboard(dpy, win, True, GrabModeAsync,
GrabModeAsync, CurrentTime) != GrabSuccess)
usleep(1000);
}
@@ -454,24 +454,6 @@ main(int argc, char *argv[]) {
eprint("dmenu: cannot open display\n");
screen = DefaultScreen(dpy);
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 */
dc.norm[ColBG] = initcolor(normbg);
dc.norm[ColFG] = initcolor(normfg);
@@ -495,6 +477,25 @@ main(int argc, char *argv[]) {
XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
if(!dc.font.set)
XSetFont(dpy, dc.gc, dc.font.xfont->fid);
+ drawmenu();
+ XMapRaised(dpy, win);
+ 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)
cmdw = textw(maxname);
if(cmdw > mw / 3)
@@ -505,8 +506,6 @@ main(int argc, char *argv[]) {
promptw = mw / 5;
text[0] = 0;
match(text);
- XMapRaised(dpy, win);
- drawmenu();
XSync(dpy, False);
/* main event loop */