add xim support

This commit is contained in:
hazen2215 2023-06-01 23:00:30 +09:00
parent 35d070b093
commit d3f7be8978
1 changed files with 22 additions and 6 deletions

28
dmenu.c
View File

@ -577,7 +577,7 @@ run(void)
XEvent ev;
while (!XNextEvent(dpy, &ev)) {
if (XFilterEvent(&ev, win))
if (XFilterEvent(&ev, None))
continue;
switch(ev.type) {
case DestroyNotify:
@ -694,15 +694,29 @@ setup(void)
CWOverrideRedirect | CWBackPixel | CWEventMask, &swa);
XSetClassHint(dpy, win, &ch);
/* input methods */
if ((xim = XOpenIM(dpy, NULL, NULL, NULL)) == NULL)
die("XOpenIM failed: could not open input device");
if ((xim = XOpenIM(dpy, NULL, NULL, NULL)) == NULL) {
XSetLocaleModifiers("@im=local");
if ((xim = XOpenIM(dpy, NULL, NULL, NULL)) == NULL) {
XSetLocaleModifiers("@im=");
if ((xim = XOpenIM(dpy, NULL, NULL, NULL)) == NULL)
die("XOpenIM failed: could not open input device");
}
}
xic = XCreateIC(xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing,
XNClientWindow, win, XNFocusWindow, win, NULL);
XNClientWindow, embed ? win : parentwin, XNFocusWindow, embed ? win : parentwin, NULL);
XMapRaised(dpy, win);
XVaNestedList preedit_attr;
XPoint spot;
spot.x = x;
spot.y = topbar ? y + mh: 0;
preedit_attr = XVaCreateNestedList(0, XNSpotLocation, &spot, NULL);
XSetICValues(xic, XNPreeditAttributes, preedit_attr, NULL);
XFree(preedit_attr);
if (embed) {
XReparentWindow(dpy, win, parentwin, x, y);
XSelectInput(dpy, parentwin, FocusChangeMask | SubstructureNotifyMask);
@ -770,6 +784,8 @@ main(int argc, char *argv[])
if (!setlocale(LC_CTYPE, "") || !XSupportsLocale())
fputs("warning: no locale support\n", stderr);
if (!XSetLocaleModifiers(""))
fputs("warning: no locale modifiers support\n", stderr);
if (!(dpy = XOpenDisplay(NULL)))
die("cannot open display");
screen = DefaultScreen(dpy);