diff options
author | sabetts <sabetts> | 2005-04-09 19:30:57 +0000 |
---|---|---|
committer | sabetts <sabetts> | 2005-04-09 19:30:57 +0000 |
commit | e3a8f7b786534df114086a9755b202160a3475f0 (patch) | |
tree | f12436cddd385c3b649e2885447c432966393ab7 /src | |
parent | 3df6eb689ece68c3ada07a4e266d2b695dbb23d7 (diff) | |
download | ratpoison-e3a8f7b786534df114086a9755b202160a3475f0.zip |
(init_user_commands): add KEY argument to meta command.
(cmd_meta): optionally use the KEY passed in as an argument.
Diffstat (limited to 'src')
-rw-r--r-- | src/actions.c | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/src/actions.c b/src/actions.c index 8f016fe..acf8426 100644 --- a/src/actions.c +++ b/src/actions.c @@ -227,7 +227,8 @@ init_user_commands() "Keymap: ", arg_KEYMAP); add_command ("listhook", cmd_listhook, 1, 1, 1, "Hook: ", arg_HOOK); - add_command ("meta", cmd_meta, 0, 0, 0); + add_command ("meta", cmd_meta, 1, 0, 0, + "key: ", arg_KEY); add_command ("msgwait", cmd_msgwait, 1, 0, 0, "", arg_NUMBER); add_command ("newkmap", cmd_newkmap, 1, 1, 1, @@ -1009,18 +1010,32 @@ cmd_source (int interactive, struct cmdarg **args) cmdret * cmd_meta (int interactive, struct cmdarg **args) { + cmdret *ret = NULL; + struct rp_key key; XEvent ev1, ev; ev = rp_current_event; if (current_window() == NULL) return cmdret_new (RET_FAILURE, NULL); - ev1.xkey.type = KeyPress; - ev1.xkey.display = dpy; - ev1.xkey.window = current_window()->w; - ev1.xkey.state = rp_mask_to_x11_mask (prefix_key.state); - ev1.xkey.keycode = XKeysymToKeycode (dpy, prefix_key.sym); + ev1.xkey.type = KeyPress; + ev1.xkey.display = dpy; + ev1.xkey.window = current_window()->w; + + if (args[0]) + { + if((ret = parse_keydesc (ARG_STRING(0), &key))) + return ret; + ev1.xkey.state = rp_mask_to_x11_mask (key.state); + if(!(ev1.xkey.keycode = XKeysymToKeycode (dpy, key.sym))) + return cmdret_new (RET_FAILURE, "meta: Couldn't convert keysym to keycode"); + } + else + { + ev1.xkey.state = rp_mask_to_x11_mask (prefix_key.state); + ev1.xkey.keycode = XKeysymToKeycode (dpy, prefix_key.sym); + } XSendEvent (dpy, current_window()->w, False, KeyPressMask, &ev1); /* XTestFakeKeyEvent (dpy, XKeysymToKeycode (dpy, 't'), True, 0); */ |