]> Pileus Git - ~andy/gtk/commitdiff
gtk: Parse keypad numbers correctly
authorBastien Nocera <hadess@hadess.net>
Wed, 16 Nov 2011 18:47:39 +0000 (18:47 +0000)
committerBastien Nocera <hadess@hadess.net>
Wed, 16 Nov 2011 18:47:39 +0000 (18:47 +0000)
Try to find keycodes for keysyms at level-0 in the keymap, but don't
fail to parse if we can find those in level-1. This fixes the
parsing of numerical keys on the keypad, which require a shift level
through Num-Lock.

https://bugzilla.gnome.org/show_bug.cgi?id=606727

gtk/gtkaccelgroup.c

index 6d30880cdae75c825222080fb35f4557494db054..18b40b6a95905f69761ce0dc46984969775862c2 100644 (file)
@@ -1380,12 +1380,20 @@ gtk_accelerator_parse_with_keycode (const gchar     *accelerator,
                 {
                   *accelerator_codes = g_new0 (guint, n_keys + 1);
 
+                  /* Prefer level-0 keys to modified keys */
                   for (i = 0, j = 0; i < n_keys; ++i)
                     {
                       if (keys[i].level == 0)
                         (*accelerator_codes)[j++] = keys[i].keycode;
                     }
 
+                  /* No level-0 keys? Find in the whole keymap */
+                  if (j == 0)
+                    {
+                      for (i = 0, j = 0; i < n_keys; ++i)
+                        (*accelerator_codes)[j++] = keys[i].keycode;
+                    }
+
                   if (j == 0)
                     {
                       g_free (*accelerator_codes);