st-im-text: don't require st_im_text_set_event_window() to be called

Tests like tests/interactive/entry.js don't call it; make sure we still
display an entry in that case.

https://bugzilla.gnome.org/show_bug.cgi?id=783484
This commit is contained in:
Cosimo Cecchi 2017-06-06 14:27:55 -07:00
parent a256a35779
commit 9e0e7a4067

View File

@ -217,10 +217,12 @@ st_im_text_realize (ClutterActor *actor)
{
StIMTextPrivate *priv = ST_IM_TEXT (actor)->priv;
g_assert (event_window != NULL);
if (event_window != NULL)
{
priv->window = g_object_ref (event_window);
gtk_im_context_set_client_window (priv->im_context, priv->window);
}
}
static void
st_im_text_unrealize (ClutterActor *actor)
@ -230,9 +232,13 @@ st_im_text_unrealize (ClutterActor *actor)
reset_im_context (self);
gtk_im_context_set_client_window (priv->im_context, NULL);
if (priv->window != NULL)
{
g_object_unref (priv->window);
priv->window = NULL;
}
}
static gboolean
key_is_modifier (guint16 keyval)
@ -277,10 +283,12 @@ static GdkEventKey *
key_event_to_gdk (ClutterKeyEvent *event_clutter)
{
GdkEventKey *event_gdk;
if (event_window == NULL)
return NULL;
event_gdk = (GdkEventKey *)gdk_event_new ((event_clutter->type == CLUTTER_KEY_PRESS) ?
GDK_KEY_PRESS : GDK_KEY_RELEASE);
g_assert (event_window != NULL);
event_gdk->window = g_object_ref (event_window);
event_gdk->send_event = FALSE;
event_gdk->time = event_clutter->time;
@ -348,12 +356,13 @@ st_im_text_captured_event (ClutterActor *actor,
{
GdkEventKey *event_gdk = key_event_to_gdk ((ClutterKeyEvent *)event);
if (gtk_im_context_filter_keypress (priv->im_context, event_gdk))
if (event_gdk && gtk_im_context_filter_keypress (priv->im_context, event_gdk))
{
priv->need_im_reset = TRUE;
result = TRUE;
}
if (event_gdk)
gdk_event_free ((GdkEvent *)event_gdk);
}