gtk: Prefer group-0 keycodes

As we don't give out information about the group or level when
giving back keycodes, we should prioritise group-0, level-0, followed by
level-0 only, and then any keycodes.

This fixes "q" being pressed when the Wacom tablet code in
gnome-settings-daemon is supposed to generate an "a" ("uk" keymap
in group-0, "fr" in group-1).

https://bugzilla.gnome.org/show_bug.cgi?id=671065
This commit is contained in:
Bastien Nocera 2012-02-29 15:05:34 +00:00
parent e9f070db0f
commit dd402bd7af

View File

@ -1378,14 +1378,24 @@ gtk_accelerator_parse_with_keycode (const gchar *accelerator,
{
*accelerator_codes = g_new0 (guint, n_keys + 1);
/* Prefer level-0 keys to modified keys */
/* Prefer level-0 group-0 keys to modified keys */
for (i = 0, j = 0; i < n_keys; ++i)
{
if (keys[i].level == 0)
if (keys[i].level == 0 && keys[i].group == 0)
(*accelerator_codes)[j++] = keys[i].keycode;
}
/* No level-0 keys? Find in the whole keymap */
/* No level-0 group-0 keys? Find in the whole group-0 */
if (j == 0)
{
for (i = 0, j = 0; i < n_keys; ++i)
{
if (keys[i].group == 0)
(*accelerator_codes)[j++] = keys[i].keycode;
}
}
/* Still nothing? Try in other groups */
if (j == 0)
{
for (i = 0, j = 0; i < n_keys; ++i)