commit c1efba4e7f01fd0d1d27f046639d9ba5b22af104
parent 8c99e0b722b5f6f1e1cdeeac26f20510ca8fb851
Author: Kris Maglione <jg@suckless.org>
Date: Wed, 15 Oct 2008 23:59:17 -0400
[menu] Grab keyboard sooner.
Diffstat:
5 files changed, 20 insertions(+), 14 deletions(-)
diff --git a/cmd/menu/main.c b/cmd/menu/main.c
@@ -247,6 +247,9 @@ main(int argc, char *argv[]) {
initdisplay();
+ xext_init();
+ menu_init();
+
if(address && *address)
client = ixp_mount(address);
else
@@ -268,9 +271,6 @@ main(int argc, char *argv[]) {
if(!font)
fatal("Can't load font %q", readctl("font "));
- xext_init();
- menu_init();
-
inbuf = Bfdopen(0, OREAD);
items = populate_list(inbuf, false);
caret_insert("", true);
diff --git a/cmd/menu/menu.c b/cmd/menu/menu.c
@@ -1,6 +1,7 @@
#include "dat.h"
#include <ctype.h>
#include <string.h>
+#include <unistd.h>
#include "fns.h"
static Window* barwin;
@@ -28,16 +29,22 @@ void
menu_init(void) {
WinAttr wa;
- ltwidth = textwidth(font, "<");
-
wa.override_redirect = 1;
wa.background_pixmap = ParentRelative;
wa.event_mask = ExposureMask | KeyPressMask;
- barwin = createwindow(&scr.root, Rect(0, 0, 1, 1), scr.depth, InputOutput,
+ barwin = createwindow(&scr.root, Rect(-1, -1, 1, 1), scr.depth, InputOutput,
&wa, CWOverrideRedirect
| CWBackPixmap
| CWEventMask);
sethandler(barwin, &handlers);
+ mapwin(barwin);
+
+ int i = 0;
+ while(!grabkeyboard(barwin)) {
+ if(i++ > 1000)
+ fatal("can't grab keyboard");
+ usleep(1000);
+ }
}
static void
@@ -189,6 +196,8 @@ menu_show(void) {
USED(menu_unmap);
+ ltwidth = textwidth(font, "<");
+
pad = (font->height & ~1)/2;
height = font->height + 2;
@@ -205,11 +214,6 @@ menu_show(void) {
mapwin(barwin);
raisewin(barwin);
menu_draw();
- if(!grabkeyboard(barwin)) {
- exit(1);
- srv.running = false;
- result = 1;
- }
}
static void
diff --git a/cmd/wmii.rc.rc b/cmd/wmii.rc.rc
@@ -118,7 +118,8 @@ fn wi_runcmd { @{
* = (wihack -tags `{wmiir read /tag/sel/ctl | sed 1q} $*) }
fn `{env | 9 sed -n 's/^fn#([^=]+).*/\1/p'}
mykeys=()
- eval exec $* & }
+ if(! ~ $* '')
+ eval exec $* & }
}
fn wi_getfuns {
diff --git a/cmd/wmii/x11.c b/cmd/wmii/x11.c
@@ -973,7 +973,7 @@ ungrabpointer(void) {
int
grabkeyboard(Window *w) {
- return XGrabKeyboard(display, w->w, false /* owner events */,
+ return XGrabKeyboard(display, w->w, true /* owner events */,
GrabModeAsync, GrabModeAsync, CurrentTime
) == GrabSuccess;
}
diff --git a/rc/rc.wmii.rc b/rc/rc.wmii.rc
@@ -217,7 +217,8 @@ key $MODKEY-Shift-c || fn $key {
key $MODKEY-a || fn $key {
Action `{wi_actions | wimenu -h $hist.action -n $histlen} &}
key $MODKEY-p || fn $key {
- ifs=() { wi_runcmd `{wimenu -h $hist.prog -n $histlen <$progs_file} & }}
+ ifs=() { cmd = `{wimenu -h $hist.prog -n $histlen <$progs_file >[2]/dev/tty} }
+ wi_runcmd $cmd & }
key $MODKEY-Return || fn $key {
wi_runcmd $WMII_TERM &}