diff options
author | Connor Lane Smith | 2011-10-17 10:11:48 +0100 |
---|---|---|
committer | Connor Lane Smith | 2011-10-17 10:11:48 +0100 |
commit | cf641ae49677ae0435780e0641d9b347a4325044 (patch) | |
tree | 417fa89837cfb318b428409cd2d0ac4b6dfc8ea0 | |
parent | 5e0156c0727fa8f225c3309f265da241a98edc08 (diff) | |
parent | 24565608cbf8572211a4a1b3fe7bbe1cf0c4fbbd (diff) |
merge xim -> default
-rw-r--r-- | dmenu.c | 22 |
1 files changed, 18 insertions, 4 deletions
@@ -58,6 +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 @@ 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 @@ keypress(XKeyEvent *ev) { 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 @@ void 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 @@ run(void) { XRaiseWindow(dc->dpy, win); break; } + } } void @@ -486,6 +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 @@ setup(void) { 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(); |