merge xim -> default
cf641ae4
1 file(s) · +18 −4
| 58 | 58 | static Item *matches, *matchend; |
|
| 59 | 59 | static Item *prev, *curr, *next, *sel; |
|
| 60 | 60 | static Window win; |
|
| 61 | + | static XIC xic; |
|
| 61 | 62 | ||
| 62 | 63 | static int (*fstrncmp)(const char *, const char *, size_t) = strncmp; |
|
| 63 | 64 | static char *(*fstrstr)(const char *, const char *) = strstr; |
|
| 229 | 230 | void |
|
| 230 | 231 | keypress(XKeyEvent *ev) { |
|
| 231 | 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 | 240 | if(ev->state & ControlMask) { |
|
| 236 | 241 | KeySym lower, upper; |
|
| 237 | 242 | ||
| 273 | 278 | switch(ksym) { |
|
| 274 | 279 | default: |
|
| 275 | 280 | if(!iscntrl(*buf)) |
|
| 276 | - | insert(buf, strlen(buf)); |
|
| 281 | + | insert(buf, len); |
|
| 277 | 282 | break; |
|
| 278 | 283 | case XK_Delete: |
|
| 279 | 284 | if(text[cursor] == '\0') |
|
| 461 | 466 | run(void) { |
|
| 462 | 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 | 472 | switch(ev.type) { |
|
| 466 | 473 | case Expose: |
|
| 467 | 474 | if(ev.xexpose.count == 0) |
|
| 479 | 486 | XRaiseWindow(dc->dpy, win); |
|
| 480 | 487 | break; |
|
| 481 | 488 | } |
|
| 489 | + | } |
|
| 482 | 490 | } |
|
| 483 | 491 | ||
| 484 | 492 | void |
|
| 486 | 494 | int x, y, screen = DefaultScreen(dc->dpy); |
|
| 487 | 495 | Window root = RootWindow(dc->dpy, screen); |
|
| 488 | 496 | XSetWindowAttributes swa; |
|
| 497 | + | XIM xim; |
|
| 489 | 498 | #ifdef XINERAMA |
|
| 490 | 499 | int n; |
|
| 491 | 500 | XineramaScreenInfo *info; |
|
| 541 | 550 | DefaultDepth(dc->dpy, screen), CopyFromParent, |
|
| 542 | 551 | DefaultVisual(dc->dpy, screen), |
|
| 543 | 552 | CWOverrideRedirect | CWBackPixmap | CWEventMask, &swa); |
|
| 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); |
|
| 544 | 558 | ||
| 545 | 559 | XMapRaised(dc->dpy, win); |
|
| 546 | 560 | resizedc(dc, mw, mh); |
|