diff options
author | Michael Natterer <mitch@lanedo.com> | 2011-11-18 12:25:03 +0100 |
---|---|---|
committer | Michael Natterer <mitch@gimp.org> | 2011-11-18 13:06:27 +0100 |
commit | 1c8481a6ea52f34210177f54159d231ea4ba0b7d (patch) | |
tree | 9583e4b0b6f7453593281f24f69b290c8e68e7c3 /gtk/gtkprivate.c | |
parent | 43dd705308c0c30b573e82cffb67992081c81b7b (diff) | |
download | gtk+-1c8481a6ea52f34210177f54159d231ea4ba0b7d.tar.gz |
Bug 663856 - Make option-foo accelerators use the right symbol
If the keyboard group shifting modifier is *also* a normal
accelerator modifier, we need to special case it when calling
gdk_keymap_translate_keyboard_state(), so we get the right
key symbol for accelerators (for example we want Option-O,
not Option-Ø displayed in menu items). This patch should only
affect quartz where the Alt key both shifts the group and can
be used as accel modifier, and not X11 or Win32 where AltGr
is not used for accelerators.
- fix quartz' gdk_keymap_translate_keyboard_state() to return
the right consumed_modifiers
- add _gtk_translate_keyboard_accel_state() which does the
special casing
- use it everywhere instead of gdk_keymap_translate_keyboard_state()
Diffstat (limited to 'gtk/gtkprivate.c')
-rw-r--r-- | gtk/gtkprivate.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/gtk/gtkprivate.c b/gtk/gtkprivate.c index 73275fc13b..1ec08147fb 100644 --- a/gtk/gtkprivate.c +++ b/gtk/gtkprivate.c @@ -204,3 +204,48 @@ _gtk_get_primary_accel_mod (void) return primary; } + +gboolean +_gtk_translate_keyboard_accel_state (GdkKeymap *keymap, + guint hardware_keycode, + GdkModifierType state, + GdkModifierType accel_mask, + gint group, + guint *keyval, + gint *effective_group, + gint *level, + GdkModifierType *consumed_modifiers) +{ + gboolean group_mask_disabled = FALSE; + gboolean retval; + + /* if the group-toggling modifier is part of the accel mod mask, and + * it is active, disable it for matching + */ + if (accel_mask & state & GTK_TOGGLE_GROUP_MOD_MASK) + { + state &= ~GTK_TOGGLE_GROUP_MOD_MASK; + group = 0; + group_mask_disabled = TRUE; + } + + retval = gdk_keymap_translate_keyboard_state (keymap, + hardware_keycode, state, group, + keyval, + effective_group, level, + consumed_modifiers); + + /* add back the group mask, we want to match against the modifier, + * but not against the keyval from its group + */ + if (group_mask_disabled) + { + if (effective_group) + *effective_group = 1; + + if (consumed_modifiers) + *consumed_modifiers &= ~GTK_TOGGLE_GROUP_MOD_MASK; + } + + return retval; +} |