Index: ChangeLog =================================================================== RCS file: /sources/ratpoison/ratpoison/ChangeLog,v retrieving revision 1.466 diff -u -p -r1.466 ChangeLog --- ChangeLog 8 Mar 2007 08:43:35 -0000 1.466 +++ ChangeLog 21 Apr 2007 12:52:28 -0000 @@ -1,3 +1,22 @@ +2007-04-21 Bernhard R. Link
+ + * src/actions.h (find_keybinding_by_x11_mask): new prototype + + * src/actions.c (find_keybinding_by_x11_mask): new function + finding the first binding that differs only by states X11 + cannot currently distringuish. + (cmd_readkey, cmd_describekey): use find_keybinding_by_x11_mask. + (cmd_resize): compare X11 masks, too. + + * src/events.c (handle_key): use find_keybinding_by_x11_mask + + * src/data.h (struct modifier_info): new translated_states + member to fast-translate states to X11 modifier masks. + + * src/input.c (update_modifier_map): generate translated_states + after modifier update. No longer disable Alt when overlapping with + Meta. + 2007-03-08 Shawn Betts * src/split.c (set_active_frame): call switch_frame hook Index: src/actions.c =================================================================== RCS file: /sources/ratpoison/ratpoison/src/actions.c,v retrieving revision 1.285 diff -u -p -r1.285 actions.c --- src/actions.c 8 Mar 2007 08:43:36 -0000 1.285 +++ src/actions.c 21 Apr 2007 12:52:28 -0000 @@ -486,6 +486,20 @@ find_keybinding (KeySym keysym, unsigned return NULL; } +rp_action* +find_keybinding_by_x11_mask (KeySym keysym, unsigned int mod, rp_keymap *map) +{ + int i; + for (i = 0; i < map->actions_last; i++) + { + if (map->actions[i].key == keysym + && rp_modifier_info.translated_states[map->actions[i].state] == mod) + return &map->actions[i]; + } + return NULL; +} + + static char * find_command_by_keydesc (char *desc, rp_keymap *map) { @@ -2946,13 +2960,11 @@ cmd_resize (int interactive, struct cmda show_frame_message ("Resize frame"); nbytes = read_key (&c, &mod, buffer, sizeof (buffer)); - /* Convert the mask to be compatible with ratpoison. */ - mod = x11_mask_to_rp_mask (mod); - for (binding = resize_bindings; binding->action; binding++) { - if (c == binding->key.sym && mod == binding->key.state) - break; + if (c == binding->key.sym + && mod == rp_modifier_info.translated_states[binding->key.state]) + break; } if (binding->action == RESIZE_VGROW) @@ -4931,7 +4943,7 @@ cmd_readkey (int interactive, struct cmd if (rat_grabbed) ungrab_rat(); - if ((key_action = find_keybinding (keysym, x11_mask_to_rp_mask (mod), map))) + if ((key_action = find_keybinding_by_x11_mask (keysym, mod, map))) { return command (1, key_action->data); } @@ -5484,7 +5496,7 @@ cmd_describekey (int interactive, struct if (rat_grabbed) ungrab_rat(); - if ((key_action = find_keybinding (keysym, x11_mask_to_rp_mask (mod), map))) + if ((key_action = find_keybinding_by_x11_mask (keysym, mod, map))) { cmdret *ret; keysym_name = keysym_to_string (keysym, x11_mask_to_rp_mask (mod)); Index: src/actions.h =================================================================== RCS file: /sources/ratpoison/ratpoison/src/actions.h,v retrieving revision 1.91 diff -u -p -r1.91 actions.h --- src/actions.h 26 Nov 2006 23:54:36 -0000 1.91 +++ src/actions.h 21 Apr 2007 12:52:28 -0000 @@ -226,6 +226,7 @@ void free_aliases (void); void free_keymaps (void); char *wingravity_to_string (int g); rp_action* find_keybinding (KeySym keysym, unsigned int state, rp_keymap *map); +rp_action* find_keybinding_by_x11_mask (KeySym keysym, unsigned int mod, rp_keymap *map); rp_action* find_keybinding_by_action (char *action, rp_keymap *map); Index: src/data.h =================================================================== RCS file: /sources/ratpoison/ratpoison/src/data.h,v retrieving revision 1.74 diff -u -p -r1.74 data.h --- src/data.h 8 Mar 2007 08:43:36 -0000 1.74 +++ src/data.h 21 Apr 2007 12:52:28 -0000 @@ -296,6 +296,8 @@ struct rp_child_info #define RP_ALT_MASK 8 #define RP_SUPER_MASK 16 #define RP_HYPER_MASK 32 +/* size of table for all possible combinatons */ +#define RP_MASK_SIZE 64 struct modifier_info { @@ -309,6 +311,9 @@ struct modifier_info ignored. */ unsigned int num_lock_mask; unsigned int scroll_lock_mask; + + /* fast translation table for keysym tables */ + unsigned int translated_states[RP_MASK_SIZE]; }; typedef struct list_head *(*completion_fn)(char *string); Index: src/events.c =================================================================== RCS file: /sources/ratpoison/ratpoison/src/events.c,v retrieving revision 1.140 diff -u -p -r1.140 events.c --- src/events.c 8 Mar 2007 08:43:36 -0000 1.140 +++ src/events.c 21 Apr 2007 12:52:28 -0000 @@ -408,7 +408,7 @@ handle_key (KeySym ks, unsigned int mod, /* Read a key and execute the command associated with it on the default keymap. Ignore the key if it doesn't have a binding. */ - if ((key_action = find_keybinding (ks, x11_mask_to_rp_mask (mod), map))) + if ((key_action = find_keybinding_by_x11_mask (ks, mod, map))) { cmdret *result; Index: src/input.c =================================================================== RCS file: /sources/ratpoison/ratpoison/src/input.c,v retrieving revision 1.54 diff -u -p -r1.54 input.c --- src/input.c 14 Dec 2006 12:06:05 -0000 1.54 +++ src/input.c 21 Apr 2007 12:52:28 -0000 @@ -126,6 +126,7 @@ update_modifier_map (void) int min_code, max_code; int syms_per_code; KeySym *syms; + unsigned int state; rp_modifier_info.meta_mod_mask = 0; rp_modifier_info.alt_mod_mask = 0; @@ -213,15 +214,13 @@ update_modifier_map (void) rp_modifier_info.alt_mod_mask = 0; } - /* If some keys are both alt and meta, - make them just meta, not alt. */ - if (rp_modifier_info.alt_mod_mask & rp_modifier_info.meta_mod_mask) - { - rp_modifier_info.alt_mod_mask &= ~rp_modifier_info.meta_mod_mask; - } - XFree ((char *) syms); XFreeModifiermap (mods); + + for (state = 0 ; state < RP_MASK_SIZE ; state ++ ) + { + rp_modifier_info.translated_states[state] = rp_mask_to_x11_mask(state); + } } /* we need a keycode + modifier to generate the proper keysym (such as