diff options
| -rw-r--r-- | x.c | 26 |
1 files changed, 14 insertions, 12 deletions
| @@ -94,8 +94,10 @@ typedef struct { | |||
| 94 | Drawable buf; | 94 | Drawable buf; |
| 95 | GlyphFontSpec *specbuf; /* font spec buffer used for rendering */ | 95 | GlyphFontSpec *specbuf; /* font spec buffer used for rendering */ |
| 96 | Atom xembed, wmdeletewin, netwmname, netwmpid; | 96 | Atom xembed, wmdeletewin, netwmname, netwmpid; |
| 97 | XIM xim; | 97 | struct { |
| 98 | XIC xic; | 98 | XIM xim; |
| 99 | XIC xic; | ||
| 100 | } ime; | ||
| 99 | Draw draw; | 101 | Draw draw; |
| 100 | Visual *vis; | 102 | Visual *vis; |
| 101 | XSetWindowAttributes attrs; | 103 | XSetWindowAttributes attrs; |
| @@ -1026,18 +1028,18 @@ ximopen(Display *dpy) | |||
| 1026 | { | 1028 | { |
| 1027 | XIMCallback destroy = { .client_data = NULL, .callback = ximdestroy }; | 1029 | XIMCallback destroy = { .client_data = NULL, .callback = ximdestroy }; |
| 1028 | 1030 | ||
| 1029 | if ((xw.xim = XOpenIM(xw.dpy, NULL, NULL, NULL)) == NULL) { | 1031 | if ((xw.ime.xim = XOpenIM(xw.dpy, NULL, NULL, NULL)) == NULL) { |
| 1030 | XSetLocaleModifiers("@im=local"); | 1032 | XSetLocaleModifiers("@im=local"); |
| 1031 | if ((xw.xim = XOpenIM(xw.dpy, NULL, NULL, NULL)) == NULL) { | 1033 | if ((xw.ime.xim = XOpenIM(xw.dpy, NULL, NULL, NULL)) == NULL) { |
| 1032 | XSetLocaleModifiers("@im="); | 1034 | XSetLocaleModifiers("@im="); |
| 1033 | if ((xw.xim = XOpenIM(xw.dpy, NULL, NULL, NULL)) == NULL) | 1035 | if ((xw.ime.xim = XOpenIM(xw.dpy, NULL, NULL, NULL)) == NULL) |
| 1034 | die("XOpenIM failed. Could not open input device.\n"); | 1036 | die("XOpenIM failed. Could not open input device.\n"); |
| 1035 | } | 1037 | } |
| 1036 | } | 1038 | } |
| 1037 | if (XSetIMValues(xw.xim, XNDestroyCallback, &destroy, NULL) != NULL) | 1039 | if (XSetIMValues(xw.ime.xim, XNDestroyCallback, &destroy, NULL) != NULL) |
| 1038 | die("XSetIMValues failed. Could not set input method value.\n"); | 1040 | die("XSetIMValues failed. Could not set input method value.\n"); |
| 1039 | xw.xic = XCreateIC(xw.xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, | 1041 | xw.xic = XCreateIC(xw.ime.xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, |
| 1040 | XNClientWindow, xw.win, XNFocusWindow, xw.win, NULL); | 1042 | XNClientWindow, xw.win, XNFocusWindow, xw.win, NULL); |
| 1041 | if (xw.xic == NULL) | 1043 | if (xw.xic == NULL) |
| 1042 | die("XCreateIC failed. Could not obtain input method.\n"); | 1044 | die("XCreateIC failed. Could not obtain input method.\n"); |
| 1043 | } | 1045 | } |
| @@ -1053,7 +1055,7 @@ ximinstantiate(Display *dpy, XPointer client, XPointer call) | |||
| 1053 | void | 1055 | void |
| 1054 | ximdestroy(XIM xim, XPointer client, XPointer call) | 1056 | ximdestroy(XIM xim, XPointer client, XPointer call) |
| 1055 | { | 1057 | { |
| 1056 | xw.xim = NULL; | 1058 | xw.ime.xim = NULL; |
| 1057 | XRegisterIMInstantiateCallback(xw.dpy, NULL, NULL, NULL, | 1059 | XRegisterIMInstantiateCallback(xw.dpy, NULL, NULL, NULL, |
| 1058 | ximinstantiate, NULL); | 1060 | ximinstantiate, NULL); |
| 1059 | } | 1061 | } |
| @@ -1682,13 +1684,13 @@ focus(XEvent *ev) | |||
| 1682 | return; | 1684 | return; |
| 1683 | 1685 | ||
| 1684 | if (ev->type == FocusIn) { | 1686 | if (ev->type == FocusIn) { |
| 1685 | XSetICFocus(xw.xic); | 1687 | XSetICFocus(xw.ime.xic); |
| 1686 | win.mode |= MODE_FOCUSED; | 1688 | win.mode |= MODE_FOCUSED; |
| 1687 | xseturgency(0); | 1689 | xseturgency(0); |
| 1688 | if (IS_SET(MODE_FOCUS)) | 1690 | if (IS_SET(MODE_FOCUS)) |
| 1689 | ttywrite("\033[I", 3, 0); | 1691 | ttywrite("\033[I", 3, 0); |
| 1690 | } else { | 1692 | } else { |
| 1691 | XUnsetICFocus(xw.xic); | 1693 | XUnsetICFocus(xw.ime.xic); |
| 1692 | win.mode &= ~MODE_FOCUSED; | 1694 | win.mode &= ~MODE_FOCUSED; |
| 1693 | if (IS_SET(MODE_FOCUS)) | 1695 | if (IS_SET(MODE_FOCUS)) |
| 1694 | ttywrite("\033[O", 3, 0); | 1696 | ttywrite("\033[O", 3, 0); |
| @@ -1752,7 +1754,7 @@ kpress(XEvent *ev) | |||
| 1752 | if (IS_SET(MODE_KBDLOCK)) | 1754 | if (IS_SET(MODE_KBDLOCK)) |
| 1753 | return; | 1755 | return; |
| 1754 | 1756 | ||
| 1755 | len = XmbLookupString(xw.xic, e, buf, sizeof buf, &ksym, &status); | 1757 | len = XmbLookupString(xw.ime.xic, e, buf, sizeof buf, &ksym, &status); |
| 1756 | /* 1. shortcuts */ | 1758 | /* 1. shortcuts */ |
| 1757 | for (bp = shortcuts; bp < shortcuts + LEN(shortcuts); bp++) { | 1759 | for (bp = shortcuts; bp < shortcuts + LEN(shortcuts); bp++) { |
| 1758 | if (ksym == bp->keysym && match(bp->mod, e->state)) { | 1760 | if (ksym == bp->keysym && match(bp->mod, e->state)) { |
