gtk: Parse keypad numbers correctly

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
This commit is contained in:
Bastien Nocera 2011-11-16 18:47:39 +00:00
parent ef5476f16a
commit de47b90fd1

View 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);