Do not handle release key events, if engine is in init mode.
authorPeng Huang <shawn.p.huang@gmail.com>
Tue, 18 Jan 2011 15:12:40 +0000 (10:12 -0500)
committerPeng Huang <shawn.p.huang@gmail.com>
Tue, 18 Jan 2011 15:12:40 +0000 (10:12 -0500)
Most application only process key press events, but some process key release events. This change will let Pinyin engine to ignore some release events in init mode, and let applications have chance to get release key events.

BUG=none
TEST=Test within Ubuntu 10.10

Review URL: http://codereview.appspot.com/3975042

src/PYBopomofoEngine.cc
src/PYPinyinEngine.cc

index a46f229..5945eb6 100644 (file)
@@ -82,9 +82,19 @@ BopomofoEngine::processKeyEvent (guint keyval, guint keycode, guint modifiers)
                 if (!m_editors[MODE_INIT]->text ().empty ())
                     m_editors[MODE_INIT]->reset ();
                 m_props.toggleModeChinese ();
+                return TRUE;
             }
         }
-        return TRUE;
+
+        if (m_input_mode == MODE_INIT &&
+            m_editors[MODE_INIT]->text ().empty ()) {
+            /* If it is init mode, and no any previouse input text,
+             * we will let client applications to handle release key event */
+            return FALSE;
+        }
+        else {
+            return TRUE;
+        }
     }
 
     /* Toggle simp/trad Chinese Mode when hotkey Ctrl + Shift + F pressed */
index 9f7c167..f773675 100644 (file)
@@ -84,9 +84,19 @@ PinyinEngine::processKeyEvent (guint keyval, guint keycode, guint modifiers)
                 if (!m_editors[MODE_INIT]->text ().empty ())
                     m_editors[MODE_INIT]->reset ();
                 m_props.toggleModeChinese ();
+                return TRUE;
             }
         }
-        return TRUE;
+
+        if (m_input_mode == MODE_INIT &&
+            m_editors[MODE_INIT]->text ().empty ()) {
+            /* If it is init mode, and no any previouse input text,
+             * we will let client applications to handle release key event */
+            return FALSE;
+        }
+        else {
+            return TRUE;
+        }
     }
 
     /* Toggle simp/trad Chinese Mode when hotkey Ctrl + Shift + F pressed */