diff options
author | sabetts <sabetts> | 2004-04-18 21:48:42 +0000 |
---|---|---|
committer | sabetts <sabetts> | 2004-04-18 21:48:42 +0000 |
commit | c9635a8c9e89c3900a210175f0d3f3cb3723931b (patch) | |
tree | 6dc9f91a58cd7df7f3cf0156e92f07b11cfcfd29 /src/actions.c | |
parent | 996b6ae9e981fbafc10f59427f6a6f9057b2273c (diff) | |
download | ratpoison-c9635a8c9e89c3900a210175f0d3f3cb3723931b.zip |
* src/manage.h (ungrab_keys_all_wins): new prototype
(grab_keys_all_wins): likewise
* src/manage.c (grab_top_level_keys): renamed from
grab_prefix_key (all callers updated). Grab all keys in the top level keymap.
(ungrab_top_level_keys): renamed from ungrab_prefix_key (all callers updated). ungrab
all keys in the top level keymap.
(ungrab_keys_all_wins): new function
(grab_keys_all_wins): likewise
* src/globals.c: (rp_key_hook): rename from
rp_prefix_hook. Dependant code updated.
(set_rp_window_focus): change 'prefix' hook to 'key' hook.
* src/events.c (handle_key): handle a top level key press.
(handle_key): new arguments ks, and mod.
(key_press): pass the keysym and modifier to handle_key
* src/conf.h (TOP_KEYMAP): new define
* src/actions.c (cmd_v_split, cmd_h_split): swap names.
(user_commands): bind split to cmd_v_split.
(initialize_default_keybindings): initialize the top level keymap
(cmd_definekey): update the keys grabbed when changing a key on
the top level keymap.
(cmd_escape): update the escape key in the top level map.
(cmd_delkmap): don't allow the deletion of the top level keymap.
Diffstat (limited to 'src/actions.c')
-rw-r--r-- | src/actions.c | 44 |
1 files changed, 31 insertions, 13 deletions
diff --git a/src/actions.c b/src/actions.c index 79e290e..e74a7f6 100644 --- a/src/actions.c +++ b/src/actions.c @@ -362,11 +362,14 @@ add_alias (char *name, char *alias) void initialize_default_keybindings (void) { - rp_keymap *map; + rp_keymap *map, *top; map = keymap_new (ROOT_KEYMAP); list_add (&map->node, &rp_keymaps); + top = keymap_new (TOP_KEYMAP); + list_add (&top->node, &rp_keymaps); + /* Initialive the alias list. */ alias_list_size = 5; alias_list_last = 0; @@ -375,6 +378,9 @@ initialize_default_keybindings (void) prefix_key.sym = KEY_PREFIX; prefix_key.state = MODIFIER_PREFIX; + /* Add the prefix key to the top-level map. */ + add_keybinding (prefix_key.sym, prefix_key.state, "readkey " ROOT_KEYMAP, top); + add_keybinding (prefix_key.sym, prefix_key.state, "other", map); add_keybinding (prefix_key.sym, 0, "meta", map); add_keybinding (XK_g, RP_CONTROL_MASK, "abort", map); @@ -697,6 +703,11 @@ cmd_definekey (int interactive, char *data) free (tmp); } + /* If we're updating the top level map, we'll need to update the + keys grabbed. */ + if (map == find_keymap (TOP_KEYMAP)) + ungrab_keys_all_wins (); + if (!cmd || !*cmd) { /* If no comand is specified, then unbind the key. */ @@ -713,6 +724,11 @@ cmd_definekey (int interactive, char *data) add_keybinding (key->sym, key->state, cmd, map); } + /* Update the grabbed keys. */ + if (map == find_keymap (TOP_KEYMAP)) + grab_keys_all_wins (); + XSync (dpy, False); + free (keydesc); if (cmd) free (cmd); @@ -1504,11 +1520,11 @@ cmd_redisplay (int interactive, char *data) char * cmd_escape (int interactive, char *data) { - rp_window *cur; struct rp_key *key; rp_action *action; - rp_keymap *map; + rp_keymap *map, *top; + top = find_keymap (TOP_KEYMAP); map = find_keymap (ROOT_KEYMAP); key = parse_keydesc (data); @@ -1531,19 +1547,21 @@ cmd_escape (int interactive, char *data) } /* Remove the grab on the current prefix key */ - list_for_each_entry (cur, &rp_mapped_window, node) + ungrab_keys_all_wins(); + + action = find_keybinding(prefix_key.sym, prefix_key.state, top); + if (action != NULL && !strcmp (action->data, "readkey " ROOT_KEYMAP)) { - ungrab_prefix_key (cur->w); + action->key = key->sym; + action->state = key->state; } + /* Add the grab for the new prefix key */ + grab_keys_all_wins(); + + /* Finally, keep track of the current prefix. */ prefix_key.sym = key->sym; prefix_key.state = key->state; - - /* Add the grab for the new prefix key */ - list_for_each_entry (cur,&rp_mapped_window,node) - { - grab_prefix_key (cur->w); - } } else { @@ -4126,9 +4144,9 @@ cmd_delkmap (int interactive, char *data) return NULL; } - if (!strcmp (data, ROOT_KEYMAP)) + if (!strcmp (data, ROOT_KEYMAP) || !strcmp (data, TOP_KEYMAP)) { - message (" delkmap: Cannot delete '" ROOT_KEYMAP "' keymap "); + marked_message_printf (0, 0, " delkmap: Cannot delete '%s' keymap ", data); return NULL; } |