Re: [hackers] [dmenu] fix crash when XOpenIM returns NULL || Hiltjo Posthuma

From: Anselm Garbe <garbeam_AT_gmail.com>
Date: Tue, 12 Feb 2019 11:32:34 -0800

This is so ugly. People should learn English instead of using
antiquated text input methods ;)

Suckless is also about the input interface. If a typographic system
sucks, because it consists of thousands of letters, it has to be
fixed.

On Tue, 12 Feb 2019 at 10:12, <git_AT_suckless.org> wrote:
>
> commit f5036b90efd9423d805923a0bc73cd54e30e72ab
> Author: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
> AuthorDate: Tue Feb 12 19:10:43 2019 +0100
> Commit: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
> CommitDate: Tue Feb 12 19:10:43 2019 +0100
>
> fix crash when XOpenIM returns NULL
>
> for example when IME variables are set, but the program is not started (yet).
>
> diff --git a/dmenu.c b/dmenu.c
> index f803149..ae56f4f 100644
> --- a/dmenu.c
> +++ b/dmenu.c
> _AT_@ -664,8 +664,17 @@ setup(void)
> CWOverrideRedirect | CWBackPixel | CWEventMask, &swa);
> XSetClassHint(dpy, win, &ch);
>
> - /* open input methods */
> - xim = XOpenIM(dpy, NULL, NULL, NULL);
> +
> + /* input methods */
> + if ((xim = XOpenIM(dpy, NULL, NULL, NULL)) == NULL) {
> + XSetLocaleModifiers("_AT_im=local");
> + if ((xim = XOpenIM(dpy, NULL, NULL, NULL)) == NULL) {
> + XSetLocaleModifiers("_AT_im=");
> + if ((xim = XOpenIM(dpy, NULL, NULL, NULL)) == NULL)
> + die("XOpenIM failed. Could not open input device.\n");
> + }
> + }
> +
> xic = XCreateIC(xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing,
> XNClientWindow, win, XNFocusWindow, win, NULL);
>
>
Received on Tue Feb 12 2019 - 20:32:34 CET

This archive was generated by hypermail 2.3.0 : Tue Feb 12 2019 - 20:36:22 CET