From d60f1fec76be9000e02956f30bf86237e4b83f47 Mon Sep 17 00:00:00 2001 From: Makoto Kato Date: Thu, 15 Sep 2016 17:40:34 +0900 Subject: Don't set empty preedit by reset when no composing state When calling gtk_im_context_reset(), ibus-pinyin send the signals "preedit_start", "preedit_changed" (with emptry predit string), and "preeedit_end". Even if no composing state, these signals occurs. This causes some application is unexcpeted behavior. Chromium https://bugs.chromium.org/p/chromium/issues/detail?id=404005 Firefox https://bugzilla.mozilla.org/show_bug.cgi?id=1138159 So when calling gtk_im_context_reset() without composing, ibus-pinyin shouldn't send "preedit_*" signals. --- src/PYPhoneticEditor.cc | 17 ++++++++++++++++- src/PYPhoneticEditor.h | 1 + 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/PYPhoneticEditor.cc b/src/PYPhoneticEditor.cc index cd25da3..bfc5441 100644 --- a/src/PYPhoneticEditor.cc +++ b/src/PYPhoneticEditor.cc @@ -32,7 +32,8 @@ namespace PY { PhoneticEditor::PhoneticEditor (PinyinProperties & props, Config & config) : Editor (props, config), m_observer (PinyinObserver(*this)), - m_lookup_table (m_config.pageSize ()) + m_lookup_table (m_config.pageSize ()), + m_dont_update_preedit (FALSE) { } @@ -382,7 +383,18 @@ PhoneticEditor::commit (void) void PhoneticEditor::reset (void) { + const String &selected_text = m_context->selectedText (); + const String &conversion_text = m_context->conversionText (); + const String &rest_text = m_context->restText (); + + if (selected_text.empty () && conversion_text.empty () && + rest_text.empty ()) + m_dont_update_preedit = TRUE; + else + m_dont_update_preedit = FALSE; + m_context->reset(); + m_dont_update_preedit = FALSE; } void @@ -424,6 +436,9 @@ PhoneticEditor::updateAuxiliaryTextBefore (String &buffer) void PhoneticEditor::updatePreeditText (void) { + if (m_dont_update_preedit) + return; + const String &selected_text = m_context->selectedText (); const String &conversion_text = m_context->conversionText (); const String &rest_text = m_context->restText (); diff --git a/src/PYPhoneticEditor.h b/src/PYPhoneticEditor.h index 3f097ad..2510ed9 100644 --- a/src/PYPhoneticEditor.h +++ b/src/PYPhoneticEditor.h @@ -88,6 +88,7 @@ protected: std::unique_ptr m_context; PinyinObserver m_observer; LookupTable m_lookup_table; + gboolean m_dont_update_preedit; }; }; -- cgit v1.2.1