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 | |
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')
-rw-r--r-- | src/actions.c | 36 | ||||
-rw-r--r-- | src/data.h | 3 | ||||
-rw-r--r-- | src/events.c | 4 | ||||
-rw-r--r-- | src/main.c | 2 | ||||
-rw-r--r-- | src/manage.c | 4 |
5 files changed, 38 insertions, 11 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); @@ -249,6 +249,9 @@ struct rp_defaults /* How many frame sets to remember when undoing. */ int maxundos; + + /* The name of the top level keymap */ + char *top_kmap; }; /* Information about a child process. */ diff --git a/src/events.c b/src/events.c index 2ef2512..dec08b8 100644 --- a/src/events.c +++ b/src/events.c @@ -383,11 +383,11 @@ static void handle_key (KeySym ks, unsigned int mod, rp_screen *s) { rp_action *key_action; - rp_keymap *map = find_keymap (TOP_KEYMAP); + rp_keymap *map = find_keymap (defaults.top_kmap); if (map == NULL) { - PRINT_ERROR (("Unable to find " TOP_KEYMAP " keymap\n")); + PRINT_ERROR (("Unable to find %s keymap\n", defaults.top_kmap)); return; } @@ -465,6 +465,8 @@ show_welcome_message () static void init_defaults () { + defaults.top_kmap = xstrdup(TOP_KEYMAP); + defaults.win_gravity = NorthWestGravity; defaults.trans_gravity = CenterGravity; defaults.maxsize_gravity = CenterGravity; diff --git a/src/manage.c b/src/manage.c index d757cb4..f2d1a0c 100644 --- a/src/manage.c +++ b/src/manage.c @@ -110,12 +110,12 @@ grab_top_level_keys (Window w) XGrabKey(dpy, AnyKey, AnyModifier, w, True, GrabModeAsync, GrabModeAsync); #else - rp_keymap *map = find_keymap (TOP_KEYMAP); + rp_keymap *map = find_keymap (defaults.top_kmap); int i; if (map == NULL) { - PRINT_ERROR (("Unable to find " TOP_KEYMAP " keymap\n")); + PRINT_ERROR (("Unable to find %s level keymap\n", defaults.top_kmap)); return; } |