From 0ade87ef9278b03172a97f66af32f4cb2c73527a Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Sat, 16 Nov 2019 20:57:43 +0000 Subject: [PATCH] Ensure we have a client window before using it The XIM input method can some times go into weird states, especially when extended devices or in mixed environments with multiple input methods installed. Ideally, people should simply stop using XIM, which is utterly broken, and use IBus instead; nevertheless, crashing is not nice. Fixes: #61 Fixes: #518 --- modules/input/gtkimcontextxim.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/input/gtkimcontextxim.c b/modules/input/gtkimcontextxim.c index 3f1741880d..a181e5ebf8 100644 --- a/modules/input/gtkimcontextxim.c +++ b/modules/input/gtkimcontextxim.c @@ -650,6 +650,9 @@ gtk_im_context_xim_filter_keypress (GtkIMContext *context, GdkWindow *window; XKeyPressedEvent xevent; + if (context_xim->client_window == NULL) + return FALSE; + if (event->type == GDK_KEY_RELEASE && !context_xim->filter_key_release) return FALSE; @@ -1344,6 +1347,9 @@ gtk_im_context_xim_get_ic (GtkIMContextXIM *context_xim) if (context_xim->im_info == NULL || context_xim->im_info->im == NULL) return NULL; + if (context_xim->client_window == NULL) + return NULL; + if (!context_xim->ic) { const char *name1 = NULL;