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();
|
initdisplay();
|
||||||
|
|
||||||
|
xext_init();
|
||||||
|
menu_init();
|
||||||
|
|
||||||
if(address && *address)
|
if(address && *address)
|
||||||
client = ixp_mount(address);
|
client = ixp_mount(address);
|
||||||
else
|
else
|
||||||
@ -268,9 +271,6 @@ main(int argc, char *argv[]) {
|
|||||||
if(!font)
|
if(!font)
|
||||||
fatal("Can't load font %q", readctl("font "));
|
fatal("Can't load font %q", readctl("font "));
|
||||||
|
|
||||||
xext_init();
|
|
||||||
menu_init();
|
|
||||||
|
|
||||||
inbuf = Bfdopen(0, OREAD);
|
inbuf = Bfdopen(0, OREAD);
|
||||||
items = populate_list(inbuf, false);
|
items = populate_list(inbuf, false);
|
||||||
caret_insert("", true);
|
caret_insert("", true);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include "dat.h"
|
#include "dat.h"
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
#include "fns.h"
|
#include "fns.h"
|
||||||
|
|
||||||
static Window* barwin;
|
static Window* barwin;
|
||||||
@ -28,16 +29,22 @@ void
|
|||||||
menu_init(void) {
|
menu_init(void) {
|
||||||
WinAttr wa;
|
WinAttr wa;
|
||||||
|
|
||||||
ltwidth = textwidth(font, "<");
|
|
||||||
|
|
||||||
wa.override_redirect = 1;
|
wa.override_redirect = 1;
|
||||||
wa.background_pixmap = ParentRelative;
|
wa.background_pixmap = ParentRelative;
|
||||||
wa.event_mask = ExposureMask | KeyPressMask;
|
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
|
&wa, CWOverrideRedirect
|
||||||
| CWBackPixmap
|
| CWBackPixmap
|
||||||
| CWEventMask);
|
| CWEventMask);
|
||||||
sethandler(barwin, &handlers);
|
sethandler(barwin, &handlers);
|
||||||
|
mapwin(barwin);
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
while(!grabkeyboard(barwin)) {
|
||||||
|
if(i++ > 1000)
|
||||||
|
fatal("can't grab keyboard");
|
||||||
|
usleep(1000);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -189,6 +196,8 @@ menu_show(void) {
|
|||||||
|
|
||||||
USED(menu_unmap);
|
USED(menu_unmap);
|
||||||
|
|
||||||
|
ltwidth = textwidth(font, "<");
|
||||||
|
|
||||||
pad = (font->height & ~1)/2;
|
pad = (font->height & ~1)/2;
|
||||||
height = font->height + 2;
|
height = font->height + 2;
|
||||||
|
|
||||||
@ -205,11 +214,6 @@ menu_show(void) {
|
|||||||
mapwin(barwin);
|
mapwin(barwin);
|
||||||
raisewin(barwin);
|
raisewin(barwin);
|
||||||
menu_draw();
|
menu_draw();
|
||||||
if(!grabkeyboard(barwin)) {
|
|
||||||
exit(1);
|
|
||||||
srv.running = false;
|
|
||||||
result = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -118,7 +118,8 @@ fn wi_runcmd { @{
|
|||||||
* = (wihack -tags `{wmiir read /tag/sel/ctl | sed 1q} $*) }
|
* = (wihack -tags `{wmiir read /tag/sel/ctl | sed 1q} $*) }
|
||||||
fn `{env | 9 sed -n 's/^fn#([^=]+).*/\1/p'}
|
fn `{env | 9 sed -n 's/^fn#([^=]+).*/\1/p'}
|
||||||
mykeys=()
|
mykeys=()
|
||||||
eval exec $* & }
|
if(! ~ $* '')
|
||||||
|
eval exec $* & }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn wi_getfuns {
|
fn wi_getfuns {
|
||||||
|
@ -973,7 +973,7 @@ ungrabpointer(void) {
|
|||||||
int
|
int
|
||||||
grabkeyboard(Window *w) {
|
grabkeyboard(Window *w) {
|
||||||
|
|
||||||
return XGrabKeyboard(display, w->w, false /* owner events */,
|
return XGrabKeyboard(display, w->w, true /* owner events */,
|
||||||
GrabModeAsync, GrabModeAsync, CurrentTime
|
GrabModeAsync, GrabModeAsync, CurrentTime
|
||||||
) == GrabSuccess;
|
) == GrabSuccess;
|
||||||
}
|
}
|
||||||
|
@ -217,7 +217,8 @@ key $MODKEY-Shift-c || fn $key {
|
|||||||
key $MODKEY-a || fn $key {
|
key $MODKEY-a || fn $key {
|
||||||
Action `{wi_actions | wimenu -h $hist.action -n $histlen} &}
|
Action `{wi_actions | wimenu -h $hist.action -n $histlen} &}
|
||||||
key $MODKEY-p || fn $key {
|
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 {
|
key $MODKEY-Return || fn $key {
|
||||||
wi_runcmd $WMII_TERM &}
|
wi_runcmd $WMII_TERM &}
|
||||||
|
Loading…
Reference in New Issue
Block a user