X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=dmenu.c;h=5c835dd383f3bf5472f1c1ac58a60db5c006c018;hb=bbc464dc80225b8cf9390f14fac6c682f63940d2;hp=c852e92510c6679f6c4561eef307cc89d24ecc7d;hpb=b6d2cc9aea979cb3557db39dbe65a2870d13e597;p=dmenu.git diff --git a/dmenu.c b/dmenu.c index c852e92..5c835dd 100644 --- a/dmenu.c +++ b/dmenu.c @@ -6,6 +6,9 @@ #include #include #include +#ifdef __OpenBSD__ +#include +#endif #include #include @@ -144,7 +147,7 @@ drawmenu(void) drw_setscheme(drw, scheme[SchemeNorm]); drw_text(drw, x, 0, w, bh, lrpad / 2, text, 0); - drw_font_getexts(drw->fonts, text, cursor, &curpos, NULL); + curpos = TEXTW(text) - TEXTW(&text[cursor]); if ((curpos += lrpad / 2 - 1) < w) { drw_setscheme(drw, scheme[SchemeNorm]); drw_rect(drw, x + curpos, 2, 2, bh - 4, 1, 0); @@ -552,7 +555,7 @@ run(void) XEvent ev; while (!XNextEvent(dpy, &ev)) { - if (XFilterEvent(&ev, win)) + if (XFilterEvent(&ev, None)) continue; switch(ev.type) { case Expose: @@ -664,6 +667,7 @@ setup(void) XNClientWindow, win, XNFocusWindow, win, NULL); XMapRaised(dpy, win); + XSetInputFocus(dpy, win, RevertToParent, CurrentTime); if (embed) { XSelectInput(dpy, parentwin, FocusChangeMask); if (XQueryTree(dpy, parentwin, &dw, &w, &dws, &du) && dws) { @@ -729,6 +733,8 @@ main(int argc, char *argv[]) if (!setlocale(LC_CTYPE, "") || !XSupportsLocale()) fputs("warning: no locale support\n", stderr); + if (!XSetLocaleModifiers("")) + fputs("warning: no locale modifiers support\n", stderr); if (!(dpy = XOpenDisplay(NULL))) die("cannot open display"); screen = DefaultScreen(dpy); @@ -743,6 +749,11 @@ main(int argc, char *argv[]) die("no fonts could be loaded."); lrpad = drw->fonts->h; +#ifdef __OpenBSD__ + if (pledge("stdio rpath", NULL) == -1) + die("pledge"); +#endif + if (fast) { grabkeyboard(); readstdin();