keybindings: Don't use the keysym to match keybindings

We don't want to match the keysym so that e.g. an accelerator
specified as "<Super>a" works if the current keymap has a keysym other
than 'a' for that keycode which means that the accelerator would
become inaccessible in a non-latin keymap.

This is inconvenient for users that often switch keyboard layouts, or
even have different layouts in different windows, since they expect
system-level keybindings to not be affected by the current layout.

https://bugzilla.gnome.org/show_bug.cgi?id=678001
This commit is contained in:
Rui Matos 2014-02-26 19:01:52 +01:00
parent 9e51d98f4a
commit 28859c604f

View File

@ -747,7 +747,6 @@ grab_key_bindings (MetaDisplay *display)
static MetaKeyBinding * static MetaKeyBinding *
display_get_keybinding (MetaDisplay *display, display_get_keybinding (MetaDisplay *display,
unsigned int keysym,
unsigned int keycode, unsigned int keycode,
unsigned long mask) unsigned long mask)
{ {
@ -756,8 +755,7 @@ display_get_keybinding (MetaDisplay *display,
i = display->n_key_bindings - 1; i = display->n_key_bindings - 1;
while (i >= 0) while (i >= 0)
{ {
if (display->key_bindings[i].keysym == keysym && if (display->key_bindings[i].keycode == keycode &&
display->key_bindings[i].keycode == keycode &&
display->key_bindings[i].mask == mask) display->key_bindings[i].mask == mask)
{ {
return &display->key_bindings[i]; return &display->key_bindings[i];
@ -907,7 +905,6 @@ meta_display_get_keybinding_action (MetaDisplay *display,
unsigned long mask) unsigned long mask)
{ {
MetaKeyBinding *binding; MetaKeyBinding *binding;
KeySym keysym;
/* This is much more vague than the MetaDisplay::overlay-key signal, /* This is much more vague than the MetaDisplay::overlay-key signal,
* which is only emitted if the overlay-key is the only key pressed; * which is only emitted if the overlay-key is the only key pressed;
@ -918,12 +915,8 @@ meta_display_get_keybinding_action (MetaDisplay *display,
if (keycode == (unsigned int)display->overlay_key_combo.keycode) if (keycode == (unsigned int)display->overlay_key_combo.keycode)
return META_KEYBINDING_ACTION_OVERLAY_KEY; return META_KEYBINDING_ACTION_OVERLAY_KEY;
keysym = XKeycodeToKeysym (display->xdisplay, keycode, 0);
mask = mask & 0xff & ~display->ignored_modifier_mask; mask = mask & 0xff & ~display->ignored_modifier_mask;
binding = display_get_keybinding (display, keysym, keycode, mask); binding = display_get_keybinding (display, keycode, mask);
if (!binding && keycode == meta_display_get_above_tab_keycode (display))
binding = display_get_keybinding (display, META_KEY_ABOVE_TAB, keycode, mask);
if (binding) if (binding)
{ {
@ -1695,7 +1688,7 @@ process_event (MetaKeyBinding *bindings,
MetaKeyHandler *handler = bindings[i].handler; MetaKeyHandler *handler = bindings[i].handler;
if ((!window && handler->flags & META_KEY_BINDING_PER_WINDOW) || if ((!window && handler->flags & META_KEY_BINDING_PER_WINDOW) ||
(event->keyval != bindings[i].keysym) || (event->hardware_keycode != bindings[i].keycode) ||
(event->modifier_state != bindings[i].mask) || (event->modifier_state != bindings[i].mask) ||
meta_compositor_filter_keybinding (display->compositor, screen, &bindings[i])) meta_compositor_filter_keybinding (display->compositor, screen, &bindings[i]))
continue; continue;
@ -1781,7 +1774,6 @@ process_overlay_key (MetaDisplay *display,
XIAsyncDevice, event->time); XIAsyncDevice, event->time);
binding = display_get_keybinding (display, binding = display_get_keybinding (display,
display->overlay_key_combo.keysym,
display->overlay_key_combo.keycode, display->overlay_key_combo.keycode,
display->grab_mask); display->grab_mask);
if (binding && if (binding &&