diff options
| author | Hiltjo Posthuma <hiltjo@codemadness.org> | 2019-02-12 19:10:43 +0100 |
|---|---|---|
| committer | Justin Ludwig <justin@jludwig.net> | 2020-11-26 00:34:43 -0800 |
| commit | c10954a12ad8abdae6471d6770f91db34c34152e (patch) | |
| tree | 2ce17a5606115fe8de59c16c8e2b5ed92d1f126c | |
| parent | d6351cf625dc8286f7c8717edc8803237810ad45 (diff) | |
fix crash when XOpenIM returns NULL
for example when IME variables are set, but the program is not started (yet).
| -rw-r--r-- | dmenu.c | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -857,8 +857,17 @@ setup(void) CWOverrideRedirect | CWBackPixel | CWColormap | CWEventMask | CWBorderPixel, &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("@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.\n"); + } + } + xic = XCreateIC(xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, XNClientWindow, win, XNFocusWindow, win, NULL); |
