mirror of
https://github.com/0intro/wmii
synced 2024-11-22 13:52:17 +03:00
[menu] Grab keyboard sooner.
This commit is contained in:
parent
8c99e0b722
commit
c1efba4e7f
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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 {
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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 &}
|
||||
|
Loading…
Reference in New Issue
Block a user