keybindings: Rename and move keysym_to_keycode

This makes it more what it's actually doing.
This commit is contained in:
Jasper St. Pierre 2014-04-07 14:51:13 -04:00
parent 4daf20483d
commit 1d08d75108

View File

@ -342,6 +342,25 @@ get_keycodes_for_keysym (MetaDisplay *display,
return n_keycodes; return n_keycodes;
} }
static guint
get_first_keycode_for_keysym (MetaDisplay *display,
guint keysym)
{
int *keycodes;
int n_keycodes;
int keycode;
n_keycodes = get_keycodes_for_keysym (display, keysym, &keycodes);
if (n_keycodes > 0)
keycode = keycodes[0];
else
keycode = 0;
g_free (keycodes);
return keycode;
}
static void static void
reload_iso_next_group_combos (MetaDisplay *display) reload_iso_next_group_combos (MetaDisplay *display)
{ {
@ -472,16 +491,6 @@ reload_iso_next_group_combos (MetaDisplay *display)
display->iso_next_group_combos = combos; display->iso_next_group_combos = combos;
} }
static guint
keysym_to_keycode (MetaDisplay *display,
guint keysym)
{
if (keysym == META_KEY_ABOVE_TAB)
return meta_display_get_above_tab_keycode (display);
else
return XKeysymToKeycode (display->xdisplay, keysym);
}
static void static void
binding_reload_keycode_foreach (gpointer key, binding_reload_keycode_foreach (gpointer key,
gpointer value, gpointer value,
@ -491,7 +500,7 @@ binding_reload_keycode_foreach (gpointer key,
MetaKeyBinding *binding = value; MetaKeyBinding *binding = value;
if (binding->keysym) if (binding->keysym)
binding->keycode = keysym_to_keycode (display, binding->keysym); binding->keycode = get_first_keycode_for_keysym (display, binding->keysym);
} }
static void static void
@ -503,7 +512,7 @@ reload_keycodes (MetaDisplay *display)
if (display->overlay_key_combo.keysym != 0) if (display->overlay_key_combo.keysym != 0)
{ {
display->overlay_key_combo.keycode = display->overlay_key_combo.keycode =
keysym_to_keycode (display, display->overlay_key_combo.keysym); get_first_keycode_for_keysym (display, display->overlay_key_combo.keysym);
} }
else else
{ {
@ -1304,7 +1313,7 @@ meta_display_grab_accelerator (MetaDisplay *display,
} }
meta_display_devirtualize_modifiers (display, modifiers, &mask); meta_display_devirtualize_modifiers (display, modifiers, &mask);
keycode = keysym_to_keycode (display, keysym); keycode = get_first_keycode_for_keysym (display, keysym);
if (keycode == 0) if (keycode == 0)
return META_KEYBINDING_ACTION_NONE; return META_KEYBINDING_ACTION_NONE;
@ -1356,7 +1365,7 @@ meta_display_ungrab_accelerator (MetaDisplay *display,
return FALSE; return FALSE;
meta_display_devirtualize_modifiers (display, grab->combo->modifiers, &mask); meta_display_devirtualize_modifiers (display, grab->combo->modifiers, &mask);
keycode = keysym_to_keycode (display, grab->combo->keysym); keycode = get_first_keycode_for_keysym (display, grab->combo->keysym);
binding = display_get_keybinding (display, keycode, mask); binding = display_get_keybinding (display, keycode, mask);
if (binding) if (binding)