From: root Date: Fri, 6 Jan 2006 03:40:19 +0000 (+0000) Subject: *** empty log message *** X-Git-Url: http://git.openbox.org/?a=commitdiff_plain;h=c064f0530db3e73a592b7b8c2971998bae59d7c6;p=dana%2Furxvt.git *** empty log message *** --- diff --git a/src/command.C b/src/command.C index 60a8dba2..dcfe0cbd 100644 --- a/src/command.C +++ b/src/command.C @@ -869,6 +869,9 @@ rxvt_term::lookup_key (XKeyEvent &ev) } } + if (HOOK_INVOKE ((this, HOOK_KEY_PRESS, DT_XEVENT, &ev, DT_STRING_LEN, kbuf, len, DT_END))) + return; + if (len <= 0) return; /* not mapped */ @@ -1637,7 +1640,9 @@ rxvt_term::x_cb (XEvent &ev) if (ev.xany.window == vt) { - if (ev.xbutton.state & (Button1Mask | Button3Mask)) + if (HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END))) + ; // nop + else if (ev.xbutton.state & (Button1Mask | Button3Mask)) { while (XCheckTypedWindowEvent (disp, vt, MotionNotify, &ev)) ; @@ -1896,7 +1901,7 @@ rxvt_term::button_press (XButtonEvent &ev) if (ev.button != MEvent.button) MEvent.clicks = 0; - if (!HOOK_INVOKE ((this, HOOK_MOUSE_CLICK, DT_XEVENT, &ev, DT_END))) + if (!HOOK_INVOKE ((this, HOOK_BUTTON_PRESS, DT_XEVENT, &ev, DT_END))) switch (ev.button) { case Button1: @@ -2158,6 +2163,9 @@ rxvt_term::button_release (XButtonEvent &ev) && ev.button == Button1 && MEvent.clicks <= 1) selection_extend (ev.x, ev.y, 0); + if (!HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END))) + return; + switch (ev.button) { case Button1: diff --git a/src/hookinc.h b/src/hookinc.h index ce29bccc..f2c9908e 100644 --- a/src/hookinc.h +++ b/src/hookinc.h @@ -26,5 +26,8 @@ def (KEYBOARD_COMMAND) - def (MOUSE_CLICK) - def (MOUSE_MOVE) + def (KEY_PRESS) + def (KEY_RELEASE) + def (BUTTON_PRESS) + def (BUTTON_RELEASE) + def (MOTION_NOTIFY) diff --git a/src/rxvtperl.h b/src/rxvtperl.h index 6ef968e2..ceaba24b 100644 --- a/src/rxvtperl.h +++ b/src/rxvtperl.h @@ -16,6 +16,7 @@ enum data_type { DT_INT, DT_LONG, DT_STRING, + DT_STRING_LEN, DT_USTRING_LEN, DT_XEVENT, }; diff --git a/src/rxvtperl.xs b/src/rxvtperl.xs index db88dbce..52faafd6 100644 --- a/src/rxvtperl.xs +++ b/src/rxvtperl.xs @@ -471,6 +471,65 @@ rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) XPUSHs (sv_2mortal (newSVpv (va_arg (ap, char *), 0))); break; + case DT_STRING_LEN: + { + char *str = va_arg (ap, char *); + int len = va_arg (ap, int); + + XPUSHs (sv_2mortal (newSVpvn (str, len))); + } + break; + + case DT_XEVENT: + { + XEvent *xe = va_arg (ap, XEvent *); + HV *hv = newHV (); + +# define set(name, sv) hv_store (hv, # name, sizeof (# name) - 1, sv, 0) +# define setiv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSViv (val), 0) +# undef set + + setiv (type, xe->type); + setiv (send_event, xe->xany.send_event); + setiv (serial, xe->xany.serial); + + switch (xe->type) + { + case KeyPress: + case KeyRelease: + case ButtonPress: + case ButtonRelease: + case MotionNotify: + setiv (time, xe->xmotion.time); + setiv (x, xe->xmotion.x); + setiv (y, xe->xmotion.y); + setiv (x_root, xe->xmotion.x_root); + setiv (y_root, xe->xmotion.y_root); + setiv (state, xe->xmotion.state); + break; + } + + switch (xe->type) + { + case KeyPress: + case KeyRelease: + setiv (keycode, xe->xkey.keycode); + break; + + case ButtonPress: + case ButtonRelease: + setiv (button, xe->xbutton.button); + break; + + case MotionNotify: + setiv (is_hint, xe->xmotion.is_hint); + break; + } + + XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); + } + break; + case DT_USTRING_LEN: { unicode_t *ustr = va_arg (ap, unicode_t *); diff --git a/src/urxvt.pm b/src/urxvt.pm index 6b06c1ff..9d5000e4 100644 --- a/src/urxvt.pm +++ b/src/urxvt.pm @@ -263,7 +263,7 @@ Called whenever the user presses a key combination that has a C action bound to it (see description of the B resource in the @@RXVT_NAME@@(1) manpage). -=item on_key_press $term, $event +=item on_key_press $term, $event, $octets =item on_key_release $term, $event @@ -273,8 +273,12 @@ resource in the @@RXVT_NAME@@(1) manpage). =item on_motion_notify $term, $event -Called whenever the corresponding X event is received for the terminal. If -the hook returns true, then the even will be ignored by rxvt-unicode. +Called whenever the corresponding X event is received for the terminal +(see the XEvent manpage) If the hook returns true, then the even will be +ignored by rxvt-unicode. + +C additionally receives the string rxvt-unicode would +output, if any, in locale-specific encoding. subwindow.