From: Connor Lane Smith Date: Mon, 17 Oct 2011 09:11:48 +0000 (+0100) Subject: merge xim -> default X-Git-Url: https://git.armaanb.net/?a=commitdiff_plain;h=cf641ae49677ae0435780e0641d9b347a4325044;hp=-c;p=dmenu.git merge xim -> default --- cf641ae49677ae0435780e0641d9b347a4325044 diff --combined dmenu.c index dc1f236,895542d..671095e --- a/dmenu.c +++ b/dmenu.c @@@ -41,6 -41,7 +41,6 @@@ static void usage(void) static char text[BUFSIZ] = ""; static int bh, mw, mh; static int inputw, promptw; -static int lines = 0; static size_t cursor = 0; static const char *font = NULL; static const char *prompt = NULL; @@@ -48,7 -49,6 +48,7 @@@ static const char *normbgcolor = "#cccc static const char *normfgcolor = "#000000"; static const char *selbgcolor = "#0066ff"; static const char *selfgcolor = "#ffffff"; +static unsigned int lines = 0; static unsigned long normcol[ColLast]; static unsigned long selcol[ColLast]; static Atom utf8; @@@ -58,6 -58,7 +58,7 @@@ static Item *items = NULL static Item *matches, *matchend; static Item *prev, *curr, *next, *sel; static Window win; + static XIC xic; static int (*fstrncmp)(const char *, const char *, size_t) = strncmp; static char *(*fstrstr)(const char *, const char *) = strstr; @@@ -229,9 -230,13 +230,13 @@@ insert(const char *str, ssize_t n) void keypress(XKeyEvent *ev) { char buf[32]; - KeySym ksym; + int len; + KeySym ksym = NoSymbol; + Status status; - XLookupString(ev, buf, sizeof buf, &ksym, NULL); + len = XmbLookupString(xic, ev, buf, sizeof buf, &ksym, &status); + if(status == XBufferOverflow) + return; if(ev->state & ControlMask) { KeySym lower, upper; @@@ -273,7 -278,7 +278,7 @@@ switch(ksym) { default: if(!iscntrl(*buf)) - insert(buf, strlen(buf)); + insert(buf, len); break; case XK_Delete: if(text[cursor] == '\0') @@@ -461,7 -466,9 +466,9 @@@ voi run(void) { XEvent ev; - while(!XNextEvent(dc->dpy, &ev)) + while(!XNextEvent(dc->dpy, &ev)) { + if(XFilterEvent(&ev, win)) + continue; switch(ev.type) { case Expose: if(ev.xexpose.count == 0) @@@ -479,6 -486,7 +486,7 @@@ XRaiseWindow(dc->dpy, win); break; } + } } void @@@ -486,6 -494,7 +494,7 @@@ setup(void) int x, y, screen = DefaultScreen(dc->dpy); Window root = RootWindow(dc->dpy, screen); XSetWindowAttributes swa; + XIM xim; #ifdef XINERAMA int n; XineramaScreenInfo *info; @@@ -542,6 -551,11 +551,11 @@@ DefaultVisual(dc->dpy, screen), CWOverrideRedirect | CWBackPixmap | CWEventMask, &swa); + /* input methods */ + xim = XOpenIM(dc->dpy, NULL, NULL, NULL); + xic = XCreateIC(xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, + XNClientWindow, win, XNFocusWindow, win, NULL); + XMapRaised(dc->dpy, win); resizedc(dc, mw, mh); drawmenu();