diff options
author | Makoto Kato <m_kato@ga2.so-net.ne.jp> | 2016-09-15 17:40:34 +0900 |
---|---|---|
committer | Peng Huang <shawn.p.huang@gmail.com> | 2020-12-07 21:59:50 -0500 |
commit | d60f1fec76be9000e02956f30bf86237e4b83f47 (patch) | |
tree | 9ee3b8472c618b79797ae314655bc3d26d5701ee | |
parent | 753d221bfeb1e438724a2ff8168bef9953698f06 (diff) | |
download | ibus-pinyin-d60f1fec76be9000e02956f30bf86237e4b83f47.tar.gz |
Don't set empty preedit by reset when no composing statemaster
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.
-rw-r--r-- | src/PYPhoneticEditor.cc | 17 | ||||
-rw-r--r-- | src/PYPhoneticEditor.h | 1 |
2 files changed, 17 insertions, 1 deletions
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<PyZy::InputContext> m_context; PinyinObserver m_observer; LookupTable m_lookup_table; + gboolean m_dont_update_preedit; }; }; |