On Wed, Jan 23, 2019 at 01:53:56AM +0800, Ivan Tham wrote:
> Register XNDestroyCallback on IME to reinstatiate XIM.
>
> This does not solve:
> - IME not usable if st started before IME
> - st goes blank with two st in a dwm tag after restarting IME, might be
> dwm bug as it is happens to other terminal as well
> ---
> x.c | 61 +++++++++++++++++++++++++++++++++++++++++++++----------------
> 1 file changed, 45 insertions(+), 16 deletions(-)
>
> diff --git a/x.c b/x.c
> index 0422421..e5ae6a2 100644
> --- a/x.c
> +++ b/x.c
> _AT_@ -139,6 +139,9 @@ static void xdrawglyphfontspecs(const XftGlyphFontSpec *, Glyph, int, int, int);
> static void xdrawglyph(Glyph, int, int);
> static void xclear(int, int, int, int);
> static int xgeommasktogravity(int);
> +static void ximopen(Display *);
> +static void ximinstantiate(Display *, XPointer, XPointer);
> +static void ximdestroy(XIM, XPointer, XPointer);
> static void xinit(int, int);
> static void cresize(int, int);
> static void xresize(int, int);
> _AT_@ -996,6 +999,47 @@ xunloadfonts(void)
> xunloadfont(&dc.ibfont);
> }
>
> +void
> +ximopen(Display *dpy)
> +{
> + XIMCallback destroy = { .client_data = NULL, .callback = ximdestroy };
> +
> + if ((xw.xim = XOpenIM(xw.dpy, NULL, NULL, NULL)) == NULL) {
> + XSetLocaleModifiers("_AT_im=local");
> + if ((xw.xim = XOpenIM(xw.dpy, NULL, NULL, NULL)) == NULL) {
> + XSetLocaleModifiers("_AT_im=");
> + if ((xw.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)
> + 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);
> + if (xw.xic == NULL)
> + die("XCreateIC failed. Could not obtain input method.\n");
> +}
> +
> +void
> +ximinstantiate(Display *dpy, XPointer client, XPointer call)
> +{
> + ximopen(dpy);
> + XUnregisterIMInstantiateCallback(xw.dpy, NULL, NULL, NULL,
> + ximinstantiate, NULL);
> +}
> +
> +void
> +ximdestroy(XIM xim, XPointer client, XPointer call)
> +{
> + xw.xim = NULL;
> + XRegisterIMInstantiateCallback(xw.dpy, NULL, NULL, NULL,
> + ximinstantiate, NULL);
> +}
> +
> void
> xinit(int cols, int rows)
> {
> _AT_@ -1061,22 +1105,7 @@ xinit(int cols, int rows)
> xw.draw = XftDrawCreate(xw.dpy, xw.buf, xw.vis, xw.cmap);
>
> /* input methods */
> - if ((xw.xim = XOpenIM(xw.dpy, NULL, NULL, NULL)) == NULL) {
> - XSetLocaleModifiers("_AT_im=local");
> - if ((xw.xim = XOpenIM(xw.dpy, NULL, NULL, NULL)) == NULL) {
> - XSetLocaleModifiers("_AT_im=");
> - if ((xw.xim = XOpenIM(xw.dpy,
> - NULL, NULL, NULL)) == NULL) {
> - die("XOpenIM failed. Could not open input"
> - " device.\n");
> - }
> - }
> - }
> - xw.xic = XCreateIC(xw.xim, XNInputStyle, XIMPreeditNothing
> - | XIMStatusNothing, XNClientWindow, xw.win,
> - XNFocusWindow, xw.win, NULL);
> - if (xw.xic == NULL)
> - die("XCreateIC failed. Could not obtain input method.\n");
> + ximopen(xw.dpy);
>
> /* white cursor, black outline */
> cursor = XCreateFontCursor(xw.dpy, mouseshape);
> --
> 2.20.1
>
>
How to reproduce?
Which input program, window manager, etc?
--
Kind regards,
Hiltjo
Received on Wed Jan 23 2019 - 09:33:36 CET