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
This commit is contained in:
Emmanuele Bassi 2019-11-16 20:57:43 +00:00
parent 53a05daa31
commit 0ade87ef92

View File

@ -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;