all repos — st @ 99de33395126fc9708f442d155e737b9182f6ef4

st (suckless terminal) config

x: move IME variables into XWindow ime embedded struct
Quentin Rameau quinq@fifth.space
commit

99de33395126fc9708f442d155e737b9182f6ef4

parent

895e5b50a8cc835c19a45e1e328eb4dc78f5fd0c

1 files changed, 14 insertions(+), 12 deletions(-)

jump to
M x.cx.c

@@ -94,8 +94,10 @@ Window win;

Drawable buf; GlyphFontSpec *specbuf; /* font spec buffer used for rendering */ Atom xembed, wmdeletewin, netwmname, netwmpid; - XIM xim; - XIC xic; + struct { + XIM xim; + XIC xic; + } ime; Draw draw; Visual *vis; XSetWindowAttributes attrs;

@@ -1026,18 +1028,18 @@ ximopen(Display *dpy)

{ XIMCallback destroy = { .client_data = NULL, .callback = ximdestroy }; - if ((xw.xim = XOpenIM(xw.dpy, NULL, NULL, NULL)) == NULL) { + if ((xw.ime.xim = XOpenIM(xw.dpy, NULL, NULL, NULL)) == NULL) { XSetLocaleModifiers("@im=local"); - if ((xw.xim = XOpenIM(xw.dpy, NULL, NULL, NULL)) == NULL) { + if ((xw.ime.xim = XOpenIM(xw.dpy, NULL, NULL, NULL)) == NULL) { XSetLocaleModifiers("@im="); - if ((xw.xim = XOpenIM(xw.dpy, NULL, NULL, NULL)) == NULL) + if ((xw.ime.xim = XOpenIM(xw.dpy, NULL, NULL, NULL)) == NULL) die("XOpenIM failed. Could not open input device.\n"); } } - if (XSetIMValues(xw.xim, XNDestroyCallback, &destroy, NULL) != NULL) + if (XSetIMValues(xw.ime.xim, XNDestroyCallback, &destroy, NULL) != NULL) die("XSetIMValues failed. Could not set input method value.\n"); - xw.xic = XCreateIC(xw.xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, - XNClientWindow, xw.win, XNFocusWindow, xw.win, NULL); + xw.xic = XCreateIC(xw.ime.xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, + XNClientWindow, xw.win, XNFocusWindow, xw.win, NULL); if (xw.xic == NULL) die("XCreateIC failed. Could not obtain input method.\n"); }

@@ -1053,7 +1055,7 @@

void ximdestroy(XIM xim, XPointer client, XPointer call) { - xw.xim = NULL; + xw.ime.xim = NULL; XRegisterIMInstantiateCallback(xw.dpy, NULL, NULL, NULL, ximinstantiate, NULL); }

@@ -1682,13 +1684,13 @@ if (e->mode == NotifyGrab)

return; if (ev->type == FocusIn) { - XSetICFocus(xw.xic); + XSetICFocus(xw.ime.xic); win.mode |= MODE_FOCUSED; xseturgency(0); if (IS_SET(MODE_FOCUS)) ttywrite("\033[I", 3, 0); } else { - XUnsetICFocus(xw.xic); + XUnsetICFocus(xw.ime.xic); win.mode &= ~MODE_FOCUSED; if (IS_SET(MODE_FOCUS)) ttywrite("\033[O", 3, 0);

@@ -1752,7 +1754,7 @@

if (IS_SET(MODE_KBDLOCK)) return; - len = XmbLookupString(xw.xic, e, buf, sizeof buf, &ksym, &status); + len = XmbLookupString(xw.ime.xic, e, buf, sizeof buf, &ksym, &status); /* 1. shortcuts */ for (bp = shortcuts; bp < shortcuts + LEN(shortcuts); bp++) { if (ksym == bp->keysym && match(bp->mod, e->state)) {