diff options
author | sabetts <sabetts> | 2006-05-15 23:46:27 +0000 |
---|---|---|
committer | sabetts <sabetts> | 2006-05-15 23:46:27 +0000 |
commit | 4ca9e47fca39687becd9df55a540568b848bfcaa (patch) | |
tree | 4a3f9eebcc6ea125e2630e3b454e079779731021 /src/actions.c | |
parent | 687ecf6f110a5edf7f8d1b0a9886a4cada3a6e9d (diff) | |
download | ratpoison-4ca9e47fca39687becd9df55a540568b848bfcaa.zip |
* src/manage.c (grab_top_level_keys): use defaults.top_kmap for the top kmap
* src/main.c (init_defaults): init defaults.top_kmap
* src/events.c (handle_key): use defaults.top_kmap for the top kmap
* src/data.h (struct rp_defaults): new field, top_kmap
* src/actions.c (set_topkmap): new prototype
(init_set_vars): topkmap new set variable
(initialize_default_keybindings): use defaults.top_kmap for the top kmap
(cmd_undefinekey): likewise
(cmd_definekey): likewise
(cmd_escape): likewise
(cmd_delkmap): likewise
(set_topkmap): new function
Diffstat (limited to 'src/actions.c')
-rw-r--r-- | src/actions.c | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/src/actions.c b/src/actions.c index 332f5b8..9ee7bd7 100644 --- a/src/actions.c +++ b/src/actions.c @@ -63,6 +63,7 @@ static cmdret * set_winliststyle (struct cmdarg **args); static cmdret * set_framesels (struct cmdarg **args); static cmdret * set_maxundos (struct cmdarg **args); static cmdret * set_infofmt (struct cmdarg **args); +static cmdret * set_topkmap (struct cmdarg **args); LIST_HEAD(set_vars); @@ -115,6 +116,7 @@ init_set_vars() add_set_var ("winliststyle", set_winliststyle, 1, "", arg_STRING); add_set_var ("framesels", set_framesels, 1, "", arg_STRING); add_set_var ("infofmt", set_infofmt, 1, "", arg_REST); + add_set_var ("topkmap", set_topkmap, 1, "", arg_STRING); } /* rp_keymaps is ratpoison's list of keymaps. */ @@ -646,7 +648,7 @@ initialize_default_keybindings (void) map = keymap_new (ROOT_KEYMAP); list_add (&map->node, &rp_keymaps); - top = keymap_new (TOP_KEYMAP); + top = keymap_new (defaults.top_kmap); list_add (&top->node, &rp_keymaps); /* Initialive the alias list. */ @@ -974,7 +976,7 @@ cmd_undefinekey (int interactive, struct cmdarg **args) /* If we're updating the top level map, we'll need to update the keys grabbed. */ - if (map == find_keymap (TOP_KEYMAP)) + if (map == find_keymap (defaults.top_kmap)) ungrab_keys_all_wins (); /* If no comand is specified, then unbind the key. */ @@ -982,7 +984,7 @@ cmd_undefinekey (int interactive, struct cmdarg **args) ret = cmdret_new (RET_FAILURE, "undefinekey: key '%s' is not bound", ARG_STRING(1)); /* Update the grabbed keys. */ - if (map == find_keymap (TOP_KEYMAP)) + if (map == find_keymap (defaults.top_kmap)) grab_keys_all_wins (); XSync (dpy, False); @@ -1007,7 +1009,7 @@ cmd_definekey (int interactive, struct cmdarg **args) /* If we're updating the top level map, we'll need to update the keys grabbed. */ - if (map == find_keymap (TOP_KEYMAP)) + if (map == find_keymap (defaults.top_kmap)) ungrab_keys_all_wins (); if ((key_action = find_keybinding (key->sym, key->state, map))) @@ -1016,7 +1018,7 @@ cmd_definekey (int interactive, struct cmdarg **args) add_keybinding (key->sym, key->state, ARG_STRING(2), map); /* Update the grabbed keys. */ - if (map == find_keymap (TOP_KEYMAP)) + if (map == find_keymap (defaults.top_kmap)) grab_keys_all_wins (); XSync (dpy, False); @@ -2655,7 +2657,7 @@ cmd_escape (int interactive, struct cmdarg **args) rp_action *action; rp_keymap *map, *top; - top = find_keymap (TOP_KEYMAP); + top = find_keymap (defaults.top_kmap); map = find_keymap (ROOT_KEYMAP); key = ARG(0,key); @@ -3608,6 +3610,26 @@ set_infofmt (struct cmdarg **args) } static cmdret * +set_topkmap (struct cmdarg **args) +{ + if (args[0] == NULL) + return cmdret_new (RET_SUCCESS, "%s", defaults.top_kmap); + + if (!find_keymap (ARG_STRING(0))) + return cmdret_new(RET_FAILURE, "Unknown keymap %s", ARG_STRING(0)); + + ungrab_keys_all_wins(); + + free (defaults.top_kmap); + defaults.top_kmap = xstrdup (ARG_STRING(0)); + + grab_keys_all_wins(); + XSync(dpy, False); + + return cmdret_new (RET_SUCCESS, NULL); +} + +static cmdret * set_winfmt (struct cmdarg **args) { if (args[0] == NULL) @@ -4785,7 +4807,7 @@ cmd_delkmap (int interactive, struct cmdarg **args) { rp_keymap *map, *top, *root; - top = find_keymap (TOP_KEYMAP); + top = find_keymap (defaults.top_kmap); root = find_keymap (ROOT_KEYMAP); map = ARG(0,keymap); |