From 83e2e23fe103406ce8bd25898d068932592d1620 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 10 Nov 2005 17:38:09 +0000 Subject: Don't corrupt odd keymaps (#316638, Kean Johnston) 2005-11-10 Matthias Clasen Don't corrupt odd keymaps (#316638, Kean Johnston) * gdk/x11/gdkkeys-x11.c (set_symbol): Auxiliary function to handle frobbing keymaps with odd numbers of syms/code. * gdk/x11/gdkkeys-x11.c (update_keymaps): Use set_symbol() to frob the keymap. --- gdk/x11/gdkkeys-x11.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'gdk') diff --git a/gdk/x11/gdkkeys-x11.c b/gdk/x11/gdkkeys-x11.c index 25acbeb979..d21d7d256b 100644 --- a/gdk/x11/gdkkeys-x11.c +++ b/gdk/x11/gdkkeys-x11.c @@ -323,12 +323,28 @@ get_symbol (const KeySym *syms, gint index; index = KEYSYM_INDEX(keymap_x11, group, level); - if (index > keymap_x11->keysyms_per_keycode) + if (index >= keymap_x11->keysyms_per_keycode) return NoSymbol; return syms[index]; } +static void +set_symbol (KeySym *syms, + GdkKeymapX11 *keymap_x11, + gint group, + gint level, + KeySym sym) +{ + gint index; + + index = KEYSYM_INDEX(keymap_x11, group, level); + if (index >= keymap_x11->keysyms_per_keycode) + return; + + syms[index] = sym; +} + static void update_keymaps (GdkKeymapX11 *keymap_x11) { @@ -374,7 +390,7 @@ update_keymaps (GdkKeymapX11 *keymap_x11) for (i = 0 ; i < 2 ; i++) { if (get_symbol (syms, keymap_x11, i, 0) == GDK_Tab) - syms[KEYSYM_INDEX (keymap_x11, i, 1)] = GDK_ISO_Left_Tab; + set_symbol (syms, keymap_x11, i, 1, GDK_ISO_Left_Tab); } /* @@ -389,8 +405,8 @@ update_keymaps (GdkKeymapX11 *keymap_x11) gdk_keyval_convert_case (get_symbol (syms, keymap_x11, 0, 0), &lower, &upper); if (lower != upper) { - syms[KEYSYM_INDEX (keymap_x11, 0, 0)] = lower; - syms[KEYSYM_INDEX (keymap_x11, 0, 1)] = upper; + set_symbol (syms, keymap_x11, 0, 0, lower); + set_symbol (syms, keymap_x11, 0, 1, upper); } } @@ -1201,7 +1217,7 @@ MyEnhancedXkbTranslateKeyCode(register XkbDescPtr xkb, /* ---- End stuff GDK adds to the original Xlib version ---- */ - return (syms[col]!=NoSymbol); + return (syms[col] != NoSymbol); } #endif /* HAVE_XKB */ -- cgit v1.2.1