Commit b58f08bd authored by Rui Matos's avatar Rui Matos
Browse files

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
parent 3ec764d5
......@@ -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
......
......@@ -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;
}
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment