Add an "Above_Tab" pseudo-keysym

We want switching between the windows of an application to be an easily
accessible operation. The convenient and memorable keybinding is the
key above the tab key - but the keysym for that key isn't consistent
across different keyboard layouts.

Add code that figures out the key from the XKB geometry and a magic
keysym name "Above_Tab" that refers to this key and switch
the default binding for cycle_group to <Alt>Above_Tab. (This will
have no effect for the normal case of getting the key binding from
GConf until this patch is applied to Metacity as well.)

https://bugzilla.gnome.org/show_bug.cgi?id=635569
This commit is contained in:
Owen W. Taylor
2010-11-22 18:21:47 -05:00
parent ed99d12e8b
commit 4ea00e102b
7 changed files with 309 additions and 7 deletions

View File

@ -761,14 +761,50 @@ meta_ui_accelerator_parse (const char *accel,
guint *keycode,
GdkModifierType *keymask)
{
const char *above_tab;
if (accel[0] == '0' && accel[1] == 'x')
{
*keysym = 0;
*keycode = (guint) strtoul (accel, NULL, 16);
*keymask = 0;
return;
}
else
gtk_accelerator_parse (accel, keysym, keymask);
/* The key name 'Above_Tab' is special - it's not an actual keysym name,
* but rather refers to the key above the tab key. In order to use
* the GDK parsing for modifiers in combination with it, we substitute
* it with 'Tab' temporarily before calling gtk_accelerator_parse().
*/
#define is_word_character(c) (g_ascii_isalnum(c) || ((c) == '_'))
#define ABOVE_TAB "Above_Tab"
#define ABOVE_TAB_LEN 9
above_tab = strstr (accel, ABOVE_TAB);
if (above_tab &&
(above_tab == accel || !is_word_character (above_tab[-1])) &&
!is_word_character (above_tab[ABOVE_TAB_LEN]))
{
char *before = g_strndup (accel, above_tab - accel);
char *after = g_strdup (above_tab + ABOVE_TAB_LEN);
char *replaced = g_strconcat (before, "Tab", after, NULL);
gtk_accelerator_parse (replaced, NULL, keymask);
g_free (before);
g_free (after);
g_free (replaced);
*keysym = META_KEY_ABOVE_TAB;
return;
}
#undef is_word_character
#undef ABOVE_TAB
#undef ABOVE_TAB_LEN
gtk_accelerator_parse (accel, keysym, keymask);
}
gboolean