diff -ur ratpoison/AUTHORS ratpoison-patched-keypress/AUTHORS --- ratpoison/AUTHORS 2005-01-15 20:44:11.000000000 +0100 +++ ratpoison-patched-keypress/AUTHORS 2005-02-26 18:47:09.000000000 +0100 @@ -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-patched-keypress/doc/ratpoison.texi --- ratpoison/doc/ratpoison.texi 2005-02-15 07:31:08.000000000 +0100 +++ ratpoison-patched-keypress/doc/ratpoison.texi 2005-02-26 18:47:09.000000000 +0100 @@ -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-patched-keypress/src/actions.c --- ratpoison/src/actions.c 2005-02-26 03:25:46.000000000 +0100 +++ ratpoison-patched-keypress/src/actions.c 2005-02-26 19:00:53.000000000 +0100 @@ -218,6 +218,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); @@ -1006,6 +1007,40 @@ } cmdret * +cmd_keypress (int interactive, struct cmdarg **args) +{ + cmdret *ret = NULL; + struct rp_key *key; + XEvent ev1, ev; + ev = rp_current_event; + + fprintf(stderr, "debug\n", args[0]); + + 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; @@ -1017,6 +1052,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-patched-keypress/src/actions.h --- ratpoison/src/actions.h 2005-02-11 00:22:40.000000000 +0100 +++ ratpoison-patched-keypress/src/actions.h 2005-02-26 18:47:09.000000000 +0100 @@ -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);