diff options
author | Connor Lane Smith <cls@lubutu.com> | 2011-10-17 10:11:48 +0100 |
---|---|---|
committer | Connor Lane Smith <cls@lubutu.com> | 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; | |||
58 | static Item *matches, *matchend; | 58 | static Item *matches, *matchend; |
59 | static Item *prev, *curr, *next, *sel; | 59 | static Item *prev, *curr, *next, *sel; |
60 | static Window win; | 60 | static Window win; |
61 | static XIC xic; | ||
61 | 62 | ||
62 | static int (*fstrncmp)(const char *, const char *, size_t) = strncmp; | 63 | static int (*fstrncmp)(const char *, const char *, size_t) = strncmp; |
63 | static char *(*fstrstr)(const char *, const char *) = strstr; | 64 | static char *(*fstrstr)(const char *, const char *) = strstr; |
@@ -229,9 +230,13 @@ insert(const char *str, ssize_t n) { | |||
229 | void | 230 | void |
230 | keypress(XKeyEvent *ev) { | 231 | keypress(XKeyEvent *ev) { |
231 | char buf[32]; | 232 | char buf[32]; |
232 | KeySym ksym; | 233 | int len; |
234 | KeySym ksym = NoSymbol; | ||
235 | Status status; | ||
233 | 236 | ||
234 | XLookupString(ev, buf, sizeof buf, &ksym, NULL); | 237 | len = XmbLookupString(xic, ev, buf, sizeof buf, &ksym, &status); |
238 | if(status == XBufferOverflow) | ||
239 | return; | ||
235 | if(ev->state & ControlMask) { | 240 | if(ev->state & ControlMask) { |
236 | KeySym lower, upper; | 241 | KeySym lower, upper; |
237 | 242 | ||
@@ -273,7 +278,7 @@ keypress(XKeyEvent *ev) { | |||
273 | switch(ksym) { | 278 | switch(ksym) { |
274 | default: | 279 | default: |
275 | if(!iscntrl(*buf)) | 280 | if(!iscntrl(*buf)) |
276 | insert(buf, strlen(buf)); | 281 | insert(buf, len); |
277 | break; | 282 | break; |
278 | case XK_Delete: | 283 | case XK_Delete: |
279 | if(text[cursor] == '\0') | 284 | if(text[cursor] == '\0') |
@@ -461,7 +466,9 @@ void | |||
461 | run(void) { | 466 | run(void) { |
462 | XEvent ev; | 467 | XEvent ev; |
463 | 468 | ||
464 | while(!XNextEvent(dc->dpy, &ev)) | 469 | while(!XNextEvent(dc->dpy, &ev)) { |
470 | if(XFilterEvent(&ev, win)) | ||
471 | continue; | ||
465 | switch(ev.type) { | 472 | switch(ev.type) { |
466 | case Expose: | 473 | case Expose: |
467 | if(ev.xexpose.count == 0) | 474 | if(ev.xexpose.count == 0) |
@@ -479,6 +486,7 @@ run(void) { | |||
479 | XRaiseWindow(dc->dpy, win); | 486 | XRaiseWindow(dc->dpy, win); |
480 | break; | 487 | break; |
481 | } | 488 | } |
489 | } | ||
482 | } | 490 | } |
483 | 491 | ||
484 | void | 492 | void |
@@ -486,6 +494,7 @@ setup(void) { | |||
486 | int x, y, screen = DefaultScreen(dc->dpy); | 494 | int x, y, screen = DefaultScreen(dc->dpy); |
487 | Window root = RootWindow(dc->dpy, screen); | 495 | Window root = RootWindow(dc->dpy, screen); |
488 | XSetWindowAttributes swa; | 496 | XSetWindowAttributes swa; |
497 | XIM xim; | ||
489 | #ifdef XINERAMA | 498 | #ifdef XINERAMA |
490 | int n; | 499 | int n; |
491 | XineramaScreenInfo *info; | 500 | XineramaScreenInfo *info; |
@@ -542,6 +551,11 @@ setup(void) { | |||
542 | DefaultVisual(dc->dpy, screen), | 551 | DefaultVisual(dc->dpy, screen), |
543 | CWOverrideRedirect | CWBackPixmap | CWEventMask, &swa); | 552 | CWOverrideRedirect | CWBackPixmap | CWEventMask, &swa); |
544 | 553 | ||
554 | /* input methods */ | ||
555 | xim = XOpenIM(dc->dpy, NULL, NULL, NULL); | ||
556 | xic = XCreateIC(xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, | ||
557 | XNClientWindow, win, XNFocusWindow, win, NULL); | ||
558 | |||
545 | XMapRaised(dc->dpy, win); | 559 | XMapRaised(dc->dpy, win); |
546 | resizedc(dc, mw, mh); | 560 | resizedc(dc, mw, mh); |
547 | drawmenu(); | 561 | drawmenu(); |