summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog19
-rw-r--r--NEWS3
-rw-r--r--doc/ratpoison.texi5
-rw-r--r--src/actions.c36
-rw-r--r--src/data.h3
-rw-r--r--src/events.c4
-rw-r--r--src/main.c2
-rw-r--r--src/manage.c4
8 files changed, 65 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index 998bc74..1da2377 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2006-05-15 Shawn Betts <sabetts@vcn.bc.ca>
+
+ * 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
+
2006-05-14 Shawn Betts <sabetts@vcn.bc.ca>
* src/input.c (update_modifier_map): use XGetKeyboardMapping.
diff --git a/NEWS b/NEWS
index be8c238..429bb5f 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,9 @@ are permitted in any medium without royalty provided the copyright
notice and this notice are preserved.
* Changes since 1.4.0
+** new command set topkmap
+See info manual.
+
** build date in ratpoison -v
** new command sfrestore
diff --git a/doc/ratpoison.texi b/doc/ratpoison.texi
index 619fc6f..5c14837 100644
--- a/doc/ratpoison.texi
+++ b/doc/ratpoison.texi
@@ -1024,6 +1024,11 @@ key. When the user does, the command will display the command bound to
this key.
@end deffn
+@deffn Command {set topkmap} @var{kmap}
+Set the top level keymap to @var{kmap}. You might use this to swap
+between several common keymappings or to implement modes.
+@end deffn
+
@node Default Key Bindings, , Key Maps, Keystrokes
@section Default Key Bindings
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);
diff --git a/src/data.h b/src/data.h
index 79cdfb9..a3d2e51 100644
--- a/src/data.h
+++ b/src/data.h
@@ -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;
}
diff --git a/src/main.c b/src/main.c
index 45feeea..651d9a9 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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;
}