]> git.armaanb.net Git - dmenu.git/commitdiff
fix crash when XOpenIM returns NULL
authorHiltjo Posthuma <hiltjo@codemadness.org>
Tue, 12 Feb 2019 18:10:43 +0000 (19:10 +0100)
committerHiltjo Posthuma <hiltjo@codemadness.org>
Tue, 12 Feb 2019 18:10:43 +0000 (19:10 +0100)
for example when IME variables are set, but the program is not started (yet).

dmenu.c

diff --git a/dmenu.c b/dmenu.c
index f8031497c8e116a9c6e045857d679e75445fd033..ae56f4fbced707105d4cbfbf4faabcaee6dd6ffc 100644 (file)
--- a/dmenu.c
+++ b/dmenu.c
@@ -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("@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);