summaryrefslogtreecommitdiffstats
path: root/src/PYPBopomofoEngine.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/PYPBopomofoEngine.cc')
-rw-r--r--src/PYPBopomofoEngine.cc29
1 files changed, 15 insertions, 14 deletions
diff --git a/src/PYPBopomofoEngine.cc b/src/PYPBopomofoEngine.cc
index 6719b92..840c51a 100644
--- a/src/PYPBopomofoEngine.cc
+++ b/src/PYPBopomofoEngine.cc
@@ -38,6 +38,7 @@ BopomofoEngine::BopomofoEngine (IBusEngine *engine)
m_props (BopomofoConfig::instance ()),
m_prev_pressed_key (IBUS_VoidSymbol),
m_input_mode (MODE_INIT),
+ m_need_update (FALSE),
m_fallback_editor (new FallbackEditor (m_props, BopomofoConfig::instance()))
{
gint i;
@@ -150,21 +151,17 @@ BopomofoEngine::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;
- }
}
if (G_UNLIKELY (m_input_mode == MODE_INIT &&
@@ -183,12 +180,16 @@ BopomofoEngine::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;
@@ -295,7 +296,7 @@ BopomofoEngine::commitText (Text & text)
} else if (BopomofoConfig::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;
}