gtk: Fix parsing of accelerators with keycodes

GDK_KEY_VoidSymbol is not the same as keycode 0. This fixes
keycodes such as "0xb3" being parsed as "VoidSymbol" keysyms.

https://bugzilla.gnome.org/show_bug.cgi?id=663761
This commit is contained in:
Bastien Nocera 2011-11-10 10:59:44 +00:00
parent d69c7f4776
commit c30d313afc
2 changed files with 8 additions and 6 deletions

View File

@ -1323,8 +1323,6 @@ gtk_accelerator_parse_with_keycode (const gchar *accelerator,
gchar *endptr;
gint tmp_keycode;
keyval = GDK_KEY_VoidSymbol;
memcpy (keystring, accelerator, 4);
keystring [4] = '\000';
@ -1367,7 +1365,7 @@ gtk_accelerator_parse_with_keycode (const gchar *accelerator,
}
}
if (keyval != GDK_KEY_VoidSymbol && accelerator_codes != NULL)
if (keyval && accelerator_codes != NULL)
{
GdkKeymapKey *keys;
gint n_keys, i, j;

View File

@ -21,19 +21,22 @@
static void
test_one_accel (const char *accel,
const char *exp_label)
const char *exp_label,
gboolean has_keysym)
{
guint accel_key;
GdkModifierType mods;
guint *keycodes;
char *label, *name;
accel_key = 0;
gtk_accelerator_parse_with_keycode (accel,
&accel_key,
&keycodes,
&mods);
g_assert (accel_key != 0);
if (has_keysym)
g_assert (accel_key != 0);
g_assert (keycodes);
g_assert (keycodes[0] != 0);
@ -58,7 +61,8 @@ test_one_accel (const char *accel,
static void
accel (void)
{
test_one_accel ("<Primary><Alt>z", "Ctrl+Alt+Z");
test_one_accel ("0xb3", "0xb3", FALSE);
test_one_accel ("<Primary><Alt>z", "Ctrl+Alt+Z", TRUE);
}
int