faster grab
This commit is contained in:
parent
fb67bd666e
commit
d0051e7bb8
23
dmenu.c
23
dmenu.c
|
@ -57,7 +57,7 @@ static DC *dc;
|
||||||
static Item *items = NULL;
|
static Item *items = NULL;
|
||||||
static Item *matches, *matchend;
|
static Item *matches, *matchend;
|
||||||
static Item *prev, *curr, *next, *sel;
|
static Item *prev, *curr, *next, *sel;
|
||||||
static Window root, win;
|
static Window win;
|
||||||
|
|
||||||
static int (*fstrncmp)(const char *, const char *, size_t) = strncmp;
|
static int (*fstrncmp)(const char *, const char *, size_t) = strncmp;
|
||||||
|
|
||||||
|
@ -104,14 +104,14 @@ main(int argc, char *argv[]) {
|
||||||
initfont(dc, font);
|
initfont(dc, font);
|
||||||
|
|
||||||
if(fast) {
|
if(fast) {
|
||||||
setup();
|
grabkeyboard();
|
||||||
readstdin();
|
readstdin();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
readstdin();
|
readstdin();
|
||||||
setup();
|
grabkeyboard();
|
||||||
}
|
}
|
||||||
match();
|
setup();
|
||||||
run();
|
run();
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
|
@ -209,7 +209,8 @@ grabkeyboard(void) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for(i = 0; i < 1000; i++) {
|
for(i = 0; i < 1000; i++) {
|
||||||
if(!XGrabKeyboard(dc->dpy, root, True, GrabModeAsync, GrabModeAsync, CurrentTime))
|
if(XGrabKeyboard(dc->dpy, DefaultRootWindow(dc->dpy), True,
|
||||||
|
GrabModeAsync, GrabModeAsync, CurrentTime) == GrabSuccess)
|
||||||
return;
|
return;
|
||||||
usleep(1000);
|
usleep(1000);
|
||||||
}
|
}
|
||||||
|
@ -487,22 +488,21 @@ run(void) {
|
||||||
|
|
||||||
void
|
void
|
||||||
setup(void) {
|
setup(void) {
|
||||||
int x, y, screen;
|
int x, y, screen = DefaultScreen(dc->dpy);
|
||||||
|
Window root = RootWindow(dc->dpy, screen);
|
||||||
XSetWindowAttributes wa;
|
XSetWindowAttributes wa;
|
||||||
#ifdef XINERAMA
|
#ifdef XINERAMA
|
||||||
int n;
|
int n;
|
||||||
XineramaScreenInfo *info;
|
XineramaScreenInfo *info;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
screen = DefaultScreen(dc->dpy);
|
|
||||||
root = RootWindow(dc->dpy, screen);
|
|
||||||
utf8 = XInternAtom(dc->dpy, "UTF8_STRING", False);
|
|
||||||
|
|
||||||
normcol[ColBG] = getcolor(dc, normbgcolor);
|
normcol[ColBG] = getcolor(dc, normbgcolor);
|
||||||
normcol[ColFG] = getcolor(dc, normfgcolor);
|
normcol[ColFG] = getcolor(dc, normfgcolor);
|
||||||
selcol[ColBG] = getcolor(dc, selbgcolor);
|
selcol[ColBG] = getcolor(dc, selbgcolor);
|
||||||
selcol[ColFG] = getcolor(dc, selfgcolor);
|
selcol[ColFG] = getcolor(dc, selfgcolor);
|
||||||
|
|
||||||
|
utf8 = XInternAtom(dc->dpy, "UTF8_STRING", False);
|
||||||
|
|
||||||
/* menu geometry */
|
/* menu geometry */
|
||||||
bh = dc->font.height + 2;
|
bh = dc->font.height + 2;
|
||||||
lines = MAX(lines, 0);
|
lines = MAX(lines, 0);
|
||||||
|
@ -539,9 +539,10 @@ setup(void) {
|
||||||
DefaultVisual(dc->dpy, screen),
|
DefaultVisual(dc->dpy, screen),
|
||||||
CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
|
CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
|
||||||
|
|
||||||
grabkeyboard();
|
|
||||||
resizedc(dc, mw, mh);
|
resizedc(dc, mw, mh);
|
||||||
inputw = MIN(inputw, mw/3);
|
inputw = MIN(inputw, mw/3);
|
||||||
promptw = prompt ? textw(dc, prompt) : 0;
|
promptw = prompt ? textw(dc, prompt) : 0;
|
||||||
XMapRaised(dc->dpy, win);
|
XMapRaised(dc->dpy, win);
|
||||||
|
drawmenu();
|
||||||
|
match();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user