[gnome-shell] viewSelector: Don't reset the search entry if it has preedit text



commit b58f08bda1b854b944043bb22a2358f1277904d6
Author: Rui Matos <tiagomatos gmail com>
Date:   Thu Feb 26 19:21:52 2015 +0100

    viewSelector: Don't reset the search entry if it has preedit text
    
    If users click outside the search entry while it's empty we reset and
    thus give up key focus. This means that when using an input method
    with candidate popups, interacting with the popup with a mouse click
    cancels the current input method context if there's no other text in
    the entry besides the preedit string.
    
    To avoid this we can check if the entry has preedit in addition to
    checking if it has normal text.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=745167

 js/ui/viewSelector.js |    4 +++-
 src/st/st-im-text.c   |   17 +++++++++++++++++
 src/st/st-im-text.h   |    1 +
 3 files changed, 21 insertions(+), 1 deletions(-)
---
diff --git a/js/ui/viewSelector.js b/js/ui/viewSelector.js
index ab22ff9..6856f18 100644
--- a/js/ui/viewSelector.js
+++ b/js/ui/viewSelector.js
@@ -552,7 +552,9 @@ const ViewSelector = new Lang.Class({
     _onCapturedEvent: function(actor, event) {
         if (event.type() == Clutter.EventType.BUTTON_PRESS) {
             let source = event.get_source();
-            if (source != this._text && this._text.text == '' &&
+            if (source != this._text &&
+                this._text.text == '' &&
+                !this._text.has_preedit () &&
                 !Main.layoutManager.keyboardBox.contains(source)) {
                 // the user clicked outside after activating the entry, but
                 // with no search term entered and no keyboard button pressed
diff --git a/src/st/st-im-text.c b/src/st/st-im-text.c
index 5666e7a..12b7e3f 100644
--- a/src/st/st-im-text.c
+++ b/src/st/st-im-text.c
@@ -67,6 +67,7 @@ struct _StIMTextPrivate
   GdkWindow *window;
 
   guint need_im_reset : 1;
+  guint has_preedit   : 1;
 };
 
 G_DEFINE_TYPE (StIMText, st_im_text, CLUTTER_TYPE_TEXT)
@@ -136,6 +137,8 @@ st_im_text_preedit_changed_cb (GtkIMContext *context,
                                    preedit_attrs,
                                    cursor_pos);
 
+  imtext->priv->has_preedit = preedit_str && *preedit_str;
+
   g_free (preedit_str);
   pango_attr_list_unref (preedit_attrs);
 }
@@ -622,3 +625,17 @@ st_im_text_get_input_hints (StIMText *imtext)
 
   return hints;
 }
+
+/**
+ * st_im_text_has_preedit:
+ * @imtext: a #StIMText
+ *
+ * Returns: wether @imtext currently has preedit text
+ */
+gboolean
+st_im_text_has_preedit (StIMText *imtext)
+{
+  g_return_val_if_fail (ST_IS_IM_TEXT (imtext), FALSE);
+
+  return imtext->priv->has_preedit;
+}
diff --git a/src/st/st-im-text.h b/src/st/st-im-text.h
index c97975a..4c96248 100644
--- a/src/st/st-im-text.h
+++ b/src/st/st-im-text.h
@@ -67,6 +67,7 @@ GtkInputPurpose st_im_text_get_input_purpose (StIMText       *imtext);
 void            st_im_text_set_input_hints   (StIMText       *imtext,
                                               GtkInputHints   hints);
 GtkInputHints   st_im_text_get_input_hints   (StIMText       *imtext);
+gboolean        st_im_text_has_preedit       (StIMText       *imtext);
 
 void            st_im_text_set_event_window  (GdkWindow      *window);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]