diff -ur ratpoison/AUTHORS ratpoison-keypress/AUTHORS --- ratpoison/AUTHORS 2005-01-15 20:44:11.000000000 +0100 +++ ratpoison-keypress/AUTHORS 2005-04-01 23:11:57.479343399 +0200 @@ -20,7 +20,7 @@ Gergely Nagy
Henrik Enberg Jonathan Walther -Martin Samuelsson +Martin Samuelsson Mike Meyer Nicklas Lindgren Pasi Kallinen diff -ur ratpoison/doc/ratpoison.texi ratpoison-keypress/doc/ratpoison.texi --- ratpoison/doc/ratpoison.texi 2005-02-15 07:31:08.000000000 +0100 +++ ratpoison-keypress/doc/ratpoison.texi 2005-04-01 23:11:57.481343087 +0200 @@ -1330,6 +1330,10 @@ Display a help screen that lists all bound keystrokes. @end deffn address@hidden Command keypress @var{key} +Act as the given key was pressed and send it to the current window. address@hidden deffn + @deffn Command license Display ratpoison's license. By default, this is bound to @kbd{C-t V}. @end deffn diff -ur ratpoison/src/actions.c ratpoison-keypress/src/actions.c --- ratpoison/src/actions.c 2005-03-05 19:22:48.000000000 +0100 +++ ratpoison-keypress/src/actions.c 2005-04-01 23:13:47.033274180 +0200 @@ -219,6 +219,7 @@ add_command ("hsplit", cmd_h_split, 1, 0, 0, "Split: ", arg_STRING); add_command ("info", cmd_info, 0, 0, 0); + add_command ("keypress", cmd_keypress, 1, 1, 1); add_command ("kill", cmd_kill, 0, 0, 0); add_command ("lastmsg", cmd_lastmsg, 0, 0, 0); add_command ("license", cmd_license, 0, 0, 0); @@ -1007,6 +1008,38 @@ } cmdret * +cmd_keypress (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; + + if((ret = parse_keydesc (args[0]->string, &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, NULL); + + XSendEvent (dpy, current_window()->w, False, KeyPressMask, &ev1); + + /* XTestFakeKeyEvent (dpy, XKeysymToKeycode (dpy, 't'), True, 0); */ + + XSync (dpy, False); + + return cmdret_new (RET_SUCCESS, NULL); +} + + +cmdret * cmd_meta (int interactive, struct cmdarg **args) { XEvent ev1, ev; @@ -1018,6 +1051,7 @@ 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); diff -ur ratpoison/src/actions.h ratpoison-keypress/src/actions.h --- ratpoison/src/actions.h 2005-02-11 00:22:40.000000000 +0100 +++ ratpoison-keypress/src/actions.h 2005-04-01 23:11:57.487342153 +0200 @@ -136,6 +136,7 @@ RP_CMD (h_split); RP_CMD (help); RP_CMD (info); +RP_CMD (keypress); RP_CMD (kill); RP_CMD (last); RP_CMD (lastmsg);