summaryrefslogtreecommitdiff
path: root/src/keybindings.c
diff options
context:
space:
mode:
authorElijah Newren <newren gmail com>2006-08-21 19:06:26 +0000
committerElijah Newren <newren@src.gnome.org>2006-08-21 19:06:26 +0000
commit88b9efd0b7cf5a7bb9e3d1b61213cf0507c27187 (patch)
treed559b367c418d35144f9654315e5080fc497d021 /src/keybindings.c
parentb42e84898679bbc50109c2e00968c0569079db85 (diff)
downloadmetacity-88b9efd0b7cf5a7bb9e3d1b61213cf0507c27187.tar.gz
Patch from Ed Catmur to fix keybindings with hex-values (coming from
2006-08-21 Elijah Newren <newren gmail com> Patch from Ed Catmur to fix keybindings with hex-values (coming from special extended keyboard keys). #140448. * src/keybindings.c (struct _MetaKeyBinding): change keycode from KeyCode to unsigned int (comment from Elijah: why???), (reload_keycodes): only grab keysyms for keybindings that have them, (count_bindings, rebuild_binding_table): bindings can be valid either due to a valid keysym or a valid keycode, (display_get_keybinding_action, meta_change_keygrab, process_tab_grab, process_workspace_switch_grab): handle keycode as well as keysym * src/prefs.[ch] (struct MetaKeyCombo, update_binding, update_list_binding): handle keycode as well as keysym * src/ui.[ch] (meta_ui_accelerator_parse): new function special cases strings of the form "0x[0-9a-fA-F]+" and otherwise calling gtk_accelerator_parse(), (meta_ui_parse_accelerator, meta_ui_parse_modifier): call meta_ui_accelerator_parse instead of gtk_accelerator_parse.
Diffstat (limited to 'src/keybindings.c')
-rw-r--r--src/keybindings.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/src/keybindings.c b/src/keybindings.c
index 7a36cd4e..d749c420 100644
--- a/src/keybindings.c
+++ b/src/keybindings.c
@@ -238,8 +238,8 @@ struct _MetaKeyBinding
{
const char *name;
KeySym keysym;
+ KeyCode keycode;
unsigned int mask;
- unsigned int keycode;
MetaVirtualModifier modifiers;
const MetaKeyHandler *handler;
};
@@ -563,8 +563,9 @@ reload_keycodes (MetaDisplay *display)
i = 0;
while (i < display->n_screen_bindings)
{
- display->screen_bindings[i].keycode = XKeysymToKeycode (display->xdisplay,
- display->screen_bindings[i].keysym);
+ if (display->screen_bindings[i].keycode == 0)
+ display->screen_bindings[i].keycode = XKeysymToKeycode (
+ display->xdisplay, display->screen_bindings[i].keysym);
++i;
}
@@ -577,8 +578,9 @@ reload_keycodes (MetaDisplay *display)
i = 0;
while (i < display->n_window_bindings)
{
- display->window_bindings[i].keycode = XKeysymToKeycode (display->xdisplay,
- display->window_bindings[i].keysym);
+ if (display->window_bindings[i].keycode == 0)
+ display->window_bindings[i].keycode = XKeysymToKeycode (
+ display->xdisplay, display->window_bindings[i].keysym);
++i;
}
@@ -651,7 +653,7 @@ count_bindings (const MetaKeyPref *prefs,
{
MetaKeyCombo *combo = tmp->data;
- if (combo && combo->keysym != None)
+ if (combo && (combo->keysym != None || combo->keycode != 0))
{
count += 1;
@@ -693,13 +695,13 @@ rebuild_binding_table (MetaDisplay *display,
{
MetaKeyCombo *combo = tmp->data;
- if (combo && combo->keysym != None)
+ if (combo && (combo->keysym != None || combo->keycode != 0))
{
(*bindings_p)[dest].name = prefs[src].name;
(*bindings_p)[dest].keysym = combo->keysym;
+ (*bindings_p)[dest].keycode = combo->keycode;
(*bindings_p)[dest].modifiers = combo->modifiers;
(*bindings_p)[dest].mask = 0;
- (*bindings_p)[dest].keycode = 0;
++dest;
@@ -712,10 +714,10 @@ rebuild_binding_table (MetaDisplay *display,
(*bindings_p)[dest].name = prefs[src].name;
(*bindings_p)[dest].keysym = combo->keysym;
+ (*bindings_p)[dest].keycode = combo->keycode;
(*bindings_p)[dest].modifiers = combo->modifiers |
META_VIRTUAL_SHIFT_MASK;
(*bindings_p)[dest].mask = 0;
- (*bindings_p)[dest].keycode = 0;
++dest;
}
@@ -816,6 +818,7 @@ regrab_window_bindings (MetaDisplay *display)
static MetaKeyBindingAction
display_get_keybinding_action (MetaDisplay *display,
unsigned int keysym,
+ unsigned int keycode,
unsigned long mask)
{
int i;
@@ -824,6 +827,7 @@ display_get_keybinding_action (MetaDisplay *display,
while (i >= 0)
{
if (display->screen_bindings[i].keysym == keysym &&
+ display->screen_bindings[i].keycode == keycode &&
display->screen_bindings[i].mask == mask)
{
return meta_prefs_get_keybinding_action (display->screen_bindings[i].name);
@@ -982,9 +986,9 @@ meta_change_keygrab (MetaDisplay *display,
*/
meta_topic (META_DEBUG_KEYBINDINGS,
- "%s keybinding %s mask 0x%x on 0x%lx\n",
+ "%s keybinding %s keycode %d mask 0x%x on 0x%lx\n",
grab ? "Grabbing" : "Ungrabbing",
- keysym_name (keysym),
+ keysym_name (keysym), keycode,
modmask, xwindow);
/* efficiency, avoid so many XSync() */
@@ -2421,6 +2425,7 @@ process_tab_grab (MetaDisplay *display,
prev_window = meta_display_lookup_x_window (display, prev_xwindow);
action = display_get_keybinding_action (display,
keysym,
+ event->xkey.keycode,
display->grab_mask);
/* Cancel when alt-Escape is pressed during using alt-Tab, and vice
@@ -2881,6 +2886,7 @@ process_workspace_switch_grab (MetaDisplay *display,
action = display_get_keybinding_action (display,
keysym,
+ event->xkey.keycode,
display->grab_mask);
switch (action)