summaryrefslogtreecommitdiffstats
path: root/src/PYPPinyinEngine.cc
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2018-06-25 11:27:07 +0800
committerPeng Wu <alexepico@gmail.com>2018-06-25 11:27:07 +0800
commit84b4fd5a6345e5ef042549affaa10973156c10d1 (patch)
tree043003136e6f5617a673b728faebca11662b224c /src/PYPPinyinEngine.cc
parente6438371f64fcf3791f37e30f9a66f6282276961 (diff)
downloadibus-libpinyin-84b4fd5a6345e5ef042549affaa10973156c10d1.tar.gz
ibus-libpinyin-84b4fd5a6345e5ef042549affaa10973156c10d1.tar.xz
ibus-libpinyin-84b4fd5a6345e5ef042549affaa10973156c10d1.zip
write m_need_update variable
Diffstat (limited to 'src/PYPPinyinEngine.cc')
-rw-r--r--src/PYPPinyinEngine.cc29
1 files changed, 14 insertions, 15 deletions
diff --git a/src/PYPPinyinEngine.cc b/src/PYPPinyinEngine.cc
index b48208a..a270b3f 100644
--- a/src/PYPPinyinEngine.cc
+++ b/src/PYPPinyinEngine.cc
@@ -48,6 +48,7 @@ PinyinEngine::PinyinEngine (IBusEngine *engine)
m_props (PinyinConfig::instance ()),
m_prev_pressed_key (IBUS_VoidSymbol),
m_input_mode (MODE_INIT),
+ m_need_update (FALSE),
m_fallback_editor (new FallbackEditor (m_props, PinyinConfig::instance ()))
{
gint i;
@@ -225,22 +226,17 @@ PinyinEngine::processKeyEvent (guint keyval, guint keycode, guint modifiers)
if (IBUS_Escape == keyval) {
m_editors[m_input_mode]->reset ();
m_input_mode = MODE_INIT;
- /* m_editors[m_input_mode]->reset (); */
- m_editors[m_input_mode]->update ();
+ m_editors[m_input_mode]->reset ();
+ /* m_editors[m_input_mode]->update ();*/
return TRUE;
}
- switch (keyval) {
- case IBUS_0 ... IBUS_9:
- case IBUS_space:
- case IBUS_Return:
- /* still in suggestion mode. */
- break;
+ retval = m_editors[m_input_mode]->processKeyEvent (keyval, keycode, modifiers);
- default:
+ if (retval)
+ goto out;
+ else
m_input_mode = MODE_INIT;
- break;
- }
}
/* handle normal input. */
@@ -306,12 +302,15 @@ PinyinEngine::processKeyEvent (guint keyval, guint keycode, guint modifiers)
m_input_mode = MODE_INIT;
}
- /* needed for SuggestionEditor */
- m_editors[m_input_mode]->update ();
-
if (G_UNLIKELY (!retval))
retval = m_fallback_editor->processKeyEvent (keyval, keycode, modifiers);
+out:
+ /* needed for SuggestionEditor */
+ if (m_need_update) {
+ m_editors[m_input_mode]->update ();
+ m_need_update = FALSE;
+ }
/* store ignored key event by editors */
m_prev_pressed_key = retval ? IBUS_VoidSymbol : keyval;
@@ -438,7 +437,7 @@ PinyinEngine::commitText (Text & text)
} else if (PinyinConfig::instance ().showSuggestion ()) {
m_input_mode = MODE_SUGGESTION;
m_editors[m_input_mode]->setText (text.text (), 0);
- m_editors[m_input_mode]->update ();
+ m_need_update = TRUE;
} else {
m_input_mode = MODE_INIT;
}