From 5e87fea1ee30ad2146bb28d163a99d9117c1dd3c Mon Sep 17 00:00:00 2001 From: Giovanni Campagna Date: Mon, 18 Feb 2013 01:47:34 +0100 Subject: [PATCH] StEntry: reset the cursor when unmapped We cannot reset the cursor at the next leave event, as that might happen on a NULL stage and cause a BadWindow error, so do it on unmap (which is guaranteed to happen before the stage is cleared). https://bugzilla.gnome.org/show_bug.cgi?id=694057 --- src/st/st-entry.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/st/st-entry.c b/src/st/st-entry.c index 4d0e024d3..103b8f58c 100644 --- a/src/st/st-entry.c +++ b/src/st/st-entry.c @@ -109,6 +109,7 @@ struct _StEntryPrivate gboolean hint_visible; gboolean capslock_warning_shown; + gboolean has_ibeam; }; static guint entry_signals[LAST_SIGNAL] = { 0, }; @@ -667,6 +668,13 @@ st_entry_set_cursor (StEntry *entry, dpy = clutter_x11_get_default_display (); stage = clutter_actor_get_stage (actor); + + if (stage == NULL) + { + g_warn_if_fail (!entry->priv->has_ibeam); + return; + } + wid = clutter_x11_get_stage_window (CLUTTER_STAGE (stage)); if (ibeam == None) @@ -676,6 +684,8 @@ st_entry_set_cursor (StEntry *entry, XDefineCursor (dpy, wid, ibeam); else XUndefineCursor (dpy, wid); + + entry->priv->has_ibeam = use_ibeam; } static gboolean @@ -688,6 +698,15 @@ st_entry_crossing_event (ClutterActor *actor, return FALSE; } +static void +st_entry_unmap (ClutterActor *actor) +{ + if (ST_ENTRY (actor)->priv->has_ibeam) + st_entry_set_cursor (ST_ENTRY (actor), FALSE); + + CLUTTER_ACTOR_CLASS (st_entry_parent_class)->unmap (actor); +} + static void st_entry_class_init (StEntryClass *klass) { @@ -706,6 +725,7 @@ st_entry_class_init (StEntryClass *klass) actor_class->get_preferred_width = st_entry_get_preferred_width; actor_class->get_preferred_height = st_entry_get_preferred_height; actor_class->allocate = st_entry_allocate; + actor_class->unmap = st_entry_unmap; actor_class->key_press_event = st_entry_key_press_event; actor_class->key_focus_in = st_entry_key_focus_in;