summaryrefslogtreecommitdiff
path: root/src/actions.c
diff options
context:
space:
mode:
authorsabetts <sabetts>2001-02-28 06:39:33 +0000
committersabetts <sabetts>2001-02-28 06:39:33 +0000
commit513a678413180525d1092d1254e9a0984218073d (patch)
treeeff1378fc17a77458689392018a6714cddfcea07 /src/actions.c
parent396818df3ca1346cb2f89e9a003af58a29b6a9f3 (diff)
downloadratpoison-513a678413180525d1092d1254e9a0984218073d.zip
* manage.h (ungrab_prefix_key): new prototype
(grab_prefix_key): likewise * manage.c (ungrab_prefix_key): new function * main.c (main): calls initialize_default_keybindings after init_window_list. * data.h (struct rp_action): key is of type KeySym. state is unsigned int. * conf.h (KEY_PREFIX): set to XK_t * actions.h (cmd_escape): new prototype * actions.c (cmd_escape): new function * data.h (struct key): move from actions.h (struct rp_key): rename from struct key. dependant code updated. (prefix_key): new global variable. code dependant on KEY_PREFIX and MODIFIER_PREFIX updated to use this. * actions.c: "maximize" user command calls cmd_maximize (initialize_default_keybindings): initializes prefix_key. Added "escape" command. * manage.c (force_maximize): moved from actions.c (maximize): likewise (maximize_normal): likewise (maximize_transient): likewise * actions.c (cmd_maximize): New function * main.c (handler): Prepends error message with "ERROR: ". Displays error in message bar. Returns 0. * events.c (destroy_window): sets rp_current_window to NULL when there are no more mapped windows. (destroy_window): calls set_current_window and find_window_other directly instead of cmd_other.
Diffstat (limited to 'src/actions.c')
-rw-r--r--src/actions.c67
1 files changed, 58 insertions, 9 deletions
diff --git a/src/actions.c b/src/actions.c
index 681504e..15bbe3d 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -86,8 +86,11 @@ initialize_default_keybindings (void)
key_actions = (rp_action*) malloc (sizeof (rp_action) * key_actions_table_size);
key_actions_last = 0;
- add_keybinding (XK_t, C, "other");
- add_keybinding (XK_t, 0, "generate");
+ prefix_key.sym = KEY_PREFIX;
+ prefix_key.state = MODIFIER_PREFIX;
+
+ add_keybinding (prefix_key.sym, prefix_key.state, "other");
+ add_keybinding (prefix_key.sym, 0, "generate");
add_keybinding (XK_g, C, "abort");
add_keybinding (XK_0, 0, "select 0");
add_keybinding (XK_1, 0, "select 1");
@@ -151,6 +154,7 @@ user_command user_commands[] =
{"version", cmd_version, arg_VOID},
{"bind", cmd_bind, arg_VOID},
{"source", cmd_source, arg_STRING},
+ {"escape", cmd_escape, arg_STRING},
/* the following screen commands may or may not be able to be
implemented. See the screen documentation for what should be
@@ -181,11 +185,11 @@ user_command user_commands[] =
{"startup_message", cmd_unimplemented, arg_VOID},
{0, 0, 0} };
-struct key*
+struct rp_key*
parse_keydesc (char *keydesc)
{
- static struct key key;
- struct key *p = &key;
+ static struct rp_key key;
+ struct rp_key *p = &key;
if (!keydesc)
return NULL;
@@ -231,14 +235,14 @@ cmd_bind (void *data)
message (" FIXME: cmd_bind: need a command to bind to key ");
else
{
- struct key *key = parse_keydesc (keydesc);
+ struct rp_key *key = parse_keydesc (keydesc);
if (key)
{
rp_action *key_action;
char foo[1000];
- sprintf (foo, " %ld %ld : '%s' ", key->state, key->sym, cmd);
+ sprintf (foo, " %d %ld : '%s' ", key->state, key->sym, cmd);
message (foo);
if ((key_action = find_keybinding (key->sym, key->state)))
@@ -303,8 +307,8 @@ cmd_generate (void *data)
/* ev1.xkey.x_root == */
/* ev1.xkey.y_root == */
- ev1.xkey.state = MODIFIER_PREFIX;
- ev1.xkey.keycode = XKeysymToKeycode (dpy, KEY_PREFIX);
+ ev1.xkey.state = prefix_key.state;
+ ev1.xkey.keycode = XKeysymToKeycode (dpy, prefix_key.sym);
XSendEvent (dpy, rp_current_window->w, False, KeyPressMask, &ev1);
@@ -690,3 +694,48 @@ cmd_maximize (void *data)
{
force_maximize (rp_current_window);
}
+
+/* Reassign the prefix key. */
+void
+cmd_escape (void *data)
+{
+ rp_window *cur;
+ struct rp_key *key;
+ rp_action *action;
+
+ key = parse_keydesc (data);
+
+ if (key)
+ {
+ /* Update the "generate" keybinding */
+ action = find_keybinding(prefix_key.sym, 0);
+ if (action != NULL)
+ {
+ action->key = key->sym;
+ action->state = 0;
+ }
+
+ /* Remove the grab on the current prefix key */
+ for (cur = rp_mapped_window_sentinel->next;
+ cur != rp_mapped_window_sentinel;
+ cur = cur->next)
+ {
+ ungrab_prefix_key (cur->w);
+ }
+
+ prefix_key.sym = key->sym;
+ prefix_key.state = key->state;
+
+ /* Add the grab for the new prefix key */
+ for (cur = rp_mapped_window_sentinel->next;
+ cur != rp_mapped_window_sentinel;
+ cur = cur->next)
+ {
+ grab_prefix_key (cur->w);
+ }
+ }
+ else
+ {
+ message (" FIXME: cmd_bind: couldnt parse key ");
+ }
+}