Process release key event correctly.
authorHuang Peng <shawn.p.huang@gmail.com>
Thu, 5 Mar 2009 06:39:12 +0000 (14:39 +0800)
committerHuang Peng <shawn.p.huang@gmail.com>
Thu, 5 Mar 2009 06:39:12 +0000 (14:39 +0800)
bus/inputcontext.c
src/ibushotkey.c
src/ibushotkey.h

index 663812e..4d66232 100644 (file)
@@ -2048,6 +2048,9 @@ bus_input_context_filter_keyboard_shortcuts (BusInputContext    *context,
     static GQuark next_factory;
     static GQuark prev_factory;
 
+    static guint prev_keyval = 0;
+    static guint prev_modifiers = 0;
+
     GQuark event;
 
     if (trigger == 0) {
@@ -2059,7 +2062,12 @@ bus_input_context_filter_keyboard_shortcuts (BusInputContext    *context,
     event = ibus_hotkey_profile_filter_key_event (BUS_DEFAULT_HOTKEY_PROFILE,
                                                   keyval,
                                                   modifiers,
+                                                  prev_keyval,
+                                                  prev_modifiers,
                                                   0);
+    prev_keyval = keyval;
+    prev_modifiers = modifiers;
+
     if (event == trigger) {
         if (priv->engine == NULL) {
             g_signal_emit (context, context_signals[REQUEST_ENGINE], 0, NULL);
index 0f1b314..1d3a4b3 100644 (file)
@@ -459,6 +459,8 @@ GQuark
 ibus_hotkey_profile_filter_key_event (IBusHotkeyProfile *profile,
                                       guint              keyval,
                                       guint              modifiers,
+                                      guint              prev_keyval,
+                                      guint              prev_modifiers,
                                       gpointer           user_data)
 {
     IBusHotkeyProfilePrivate *priv;
@@ -469,6 +471,10 @@ ibus_hotkey_profile_filter_key_event (IBusHotkeyProfile *profile,
         .modifiers = modifiers & priv->mask,
     };
 
+    if ((modifiers & IBUS_RELEASE_MASK) && keyval != prev_keyval) {
+        return 0;
+    }
+
     GQuark event = (GQuark) GPOINTER_TO_UINT (g_tree_lookup (priv->hotkeys, &hotkey));
 
     if (event != 0) {
index 75b0844..03331dd 100644 (file)
@@ -80,6 +80,8 @@ GQuark           ibus_hotkey_profile_filter_key_event
                                                 (IBusHotkeyProfile  *profile,
                                                  guint               keyval,
                                                  guint               modifiers,
+                                                 guint               prev_keyval,
+                                                 guint               prev_modifiers,
                                                  gpointer            user_data);
 
 G_END_DECLS