diff options
| -rw-r--r-- | dmenu.c | 18 |
1 files changed, 15 insertions, 3 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; |
| @@ -230,8 +231,10 @@ void | |||
| 230 | keypress(XKeyEvent *ev) { | 231 | keypress(XKeyEvent *ev) { |
| 231 | char buf[32]; | 232 | char buf[32]; |
| 232 | KeySym ksym; | 233 | KeySym ksym; |
| 234 | int len; | ||
| 235 | Status status; | ||
| 233 | 236 | ||
| 234 | XLookupString(ev, buf, sizeof buf, &ksym, NULL); | 237 | len = XmbLookupString(xic, ev, buf, sizeof(buf), &ksym, &status); |
| 235 | if(ev->state & ControlMask) { | 238 | if(ev->state & ControlMask) { |
| 236 | KeySym lower, upper; | 239 | KeySym lower, upper; |
| 237 | 240 | ||
| @@ -273,7 +276,7 @@ keypress(XKeyEvent *ev) { | |||
| 273 | switch(ksym) { | 276 | switch(ksym) { |
| 274 | default: | 277 | default: |
| 275 | if(!iscntrl(*buf)) | 278 | if(!iscntrl(*buf)) |
| 276 | insert(buf, strlen(buf)); | 279 | insert(buf, len); |
| 277 | break; | 280 | break; |
| 278 | case XK_Delete: | 281 | case XK_Delete: |
| 279 | if(text[cursor] == '\0') | 282 | if(text[cursor] == '\0') |
| @@ -461,7 +464,9 @@ void | |||
| 461 | run(void) { | 464 | run(void) { |
| 462 | XEvent ev; | 465 | XEvent ev; |
| 463 | 466 | ||
| 464 | while(!XNextEvent(dc->dpy, &ev)) | 467 | while(!XNextEvent(dc->dpy, &ev)) { |
| 468 | if(XFilterEvent(&ev, win)) | ||
| 469 | continue; | ||
| 465 | switch(ev.type) { | 470 | switch(ev.type) { |
| 466 | case Expose: | 471 | case Expose: |
| 467 | if(ev.xexpose.count == 0) | 472 | if(ev.xexpose.count == 0) |
| @@ -479,6 +484,7 @@ run(void) { | |||
| 479 | XRaiseWindow(dc->dpy, win); | 484 | XRaiseWindow(dc->dpy, win); |
| 480 | break; | 485 | break; |
| 481 | } | 486 | } |
| 487 | } | ||
| 482 | } | 488 | } |
| 483 | 489 | ||
| 484 | void | 490 | void |
| @@ -486,6 +492,7 @@ setup(void) { | |||
| 486 | int x, y, screen = DefaultScreen(dc->dpy); | 492 | int x, y, screen = DefaultScreen(dc->dpy); |
| 487 | Window root = RootWindow(dc->dpy, screen); | 493 | Window root = RootWindow(dc->dpy, screen); |
| 488 | XSetWindowAttributes swa; | 494 | XSetWindowAttributes swa; |
| 495 | XIM xim; | ||
| 489 | #ifdef XINERAMA | 496 | #ifdef XINERAMA |
| 490 | int n; | 497 | int n; |
| 491 | XineramaScreenInfo *info; | 498 | XineramaScreenInfo *info; |
| @@ -542,6 +549,11 @@ setup(void) { | |||
| 542 | DefaultVisual(dc->dpy, screen), | 549 | DefaultVisual(dc->dpy, screen), |
| 543 | CWOverrideRedirect | CWBackPixmap | CWEventMask, &swa); | 550 | CWOverrideRedirect | CWBackPixmap | CWEventMask, &swa); |
| 544 | 551 | ||
| 552 | /* input methods */ | ||
| 553 | xim = XOpenIM(dc->dpy, NULL, NULL, NULL); | ||
| 554 | xic = XCreateIC(xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, | ||
| 555 | XNClientWindow, win, XNFocusWindow, win, NULL); | ||
| 556 | |||
| 545 | XMapRaised(dc->dpy, win); | 557 | XMapRaised(dc->dpy, win); |
| 546 | resizedc(dc, mw, mh); | 558 | resizedc(dc, mw, mh); |
| 547 | drawmenu(); | 559 | drawmenu(); |
