summaryrefslogtreecommitdiff
path: root/gdk
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2005-11-10 17:38:09 +0000
committerMatthias Clasen <matthiasc@src.gnome.org>2005-11-10 17:38:09 +0000
commit83e2e23fe103406ce8bd25898d068932592d1620 (patch)
tree6699534fe4416fcb20a835c0eade6ec230fc646e /gdk
parent938d34c05913966ac265ec7f99d6dd4672f4b078 (diff)
downloadgtk+-83e2e23fe103406ce8bd25898d068932592d1620.tar.gz
Don't corrupt odd keymaps (#316638, Kean Johnston)
2005-11-10 Matthias Clasen <mclasen@redhat.com> 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.
Diffstat (limited to 'gdk')
-rw-r--r--gdk/x11/gdkkeys-x11.c26
1 files changed, 21 insertions, 5 deletions
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,13 +323,29 @@ 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)
{
GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (GDK_KEYMAP (keymap_x11)->display);
@@ -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 */