summaryrefslogtreecommitdiffstats
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
parente6438371f64fcf3791f37e30f9a66f6282276961 (diff)
downloadibus-libpinyin-84b4fd5a6345e5ef042549affaa10973156c10d1.tar.gz
ibus-libpinyin-84b4fd5a6345e5ef042549affaa10973156c10d1.tar.xz
ibus-libpinyin-84b4fd5a6345e5ef042549affaa10973156c10d1.zip
write m_need_update variable
-rw-r--r--src/PYPBopomofoEngine.cc29
-rw-r--r--src/PYPBopomofoEngine.h2
-rw-r--r--src/PYPPinyinEngine.cc29
-rw-r--r--src/PYPPinyinEngine.h2
4 files changed, 33 insertions, 29 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;
}
diff --git a/src/PYPBopomofoEngine.h b/src/PYPBopomofoEngine.h
index 5b2f129..a48e293 100644
--- a/src/PYPBopomofoEngine.h
+++ b/src/PYPBopomofoEngine.h
@@ -77,6 +77,8 @@ private:
MODE_LAST,
} m_input_mode;
+ gboolean m_need_update;
+
EditorPtr m_editors[MODE_LAST];
EditorPtr m_fallback_editor;
};
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;
}
diff --git a/src/PYPPinyinEngine.h b/src/PYPPinyinEngine.h
index 975ccbc..4c34ed3 100644
--- a/src/PYPPinyinEngine.h
+++ b/src/PYPPinyinEngine.h
@@ -76,6 +76,8 @@ private:
MODE_LAST,
} m_input_mode;
+ gboolean m_need_update;
+
gboolean m_double_pinyin;
EditorPtr m_editors[MODE_LAST];