[gnome-shell] st-im-text: don't require st_im_text_set_event_window() to be called
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] st-im-text: don't require st_im_text_set_event_window() to be called
- Date: Wed, 14 Jun 2017 21:00:27 +0000 (UTC)
commit 9e0e7a4067cf5b20647580711e5dfeb2b77d2522
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Tue Jun 6 14:27:55 2017 -0700
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
src/st/st-im-text.c | 27 ++++++++++++++++++---------
1 files changed, 18 insertions(+), 9 deletions(-)
---
diff --git a/src/st/st-im-text.c b/src/st/st-im-text.c
index 6498cfb..c32e8d7 100644
--- a/src/st/st-im-text.c
+++ b/src/st/st-im-text.c
@@ -217,9 +217,11 @@ st_im_text_realize (ClutterActor *actor)
{
StIMTextPrivate *priv = ST_IM_TEXT (actor)->priv;
- g_assert (event_window != NULL);
- priv->window = g_object_ref (event_window);
- gtk_im_context_set_client_window (priv->im_context, priv->window);
+ if (event_window != NULL)
+ {
+ priv->window = g_object_ref (event_window);
+ gtk_im_context_set_client_window (priv->im_context, priv->window);
+ }
}
static void
@@ -230,8 +232,12 @@ st_im_text_unrealize (ClutterActor *actor)
reset_im_context (self);
gtk_im_context_set_client_window (priv->im_context, NULL);
- g_object_unref (priv->window);
- priv->window = NULL;
+
+ if (priv->window != NULL)
+ {
+ g_object_unref (priv->window);
+ priv->window = NULL;
+ }
}
static gboolean
@@ -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,13 +356,14 @@ 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;
}
- gdk_event_free ((GdkEvent *)event_gdk);
+ if (event_gdk)
+ gdk_event_free ((GdkEvent *)event_gdk);
}
old_position = clutter_text_get_cursor_position (clutter_text);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]