*** empty log message ***
authorroot <root>
Fri, 6 Jan 2006 03:40:19 +0000 (03:40 +0000)
committerroot <root>
Fri, 6 Jan 2006 03:40:19 +0000 (03:40 +0000)
src/command.C
src/hookinc.h
src/rxvtperl.h
src/rxvtperl.xs
src/urxvt.pm

index 60a8dba22773c6c4e9ac1b15fb9564f857aa3a9c..dcfe0cbd79635a619fb405dd07963ae0bbc309ec 100644 (file)
@@ -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:
index ce29bccc4e4f00efdb3b4d91991dd257039a9344..f2c9908ee4f203d6b5f82f88ba8a11f449504ce0 100644 (file)
@@ -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)
index 6ef968e2077adece22f854e2c5c0a76d3e803f81..ceaba24bcb2b0ef3eb81b69167e4925017859918 100644 (file)
@@ -16,6 +16,7 @@ enum data_type {
   DT_INT,
   DT_LONG,
   DT_STRING,
+  DT_STRING_LEN,
   DT_USTRING_LEN,
   DT_XEVENT,
 };
index db88dbcedfa87e08bfdf298cc4c95a87c65dc2e2..52faafd6ce1df2afac969dfc52f024277e7d4bb4 100644 (file)
@@ -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 *);
index 6b06c1ffbb77f43b260bd9a0cd27fc2c20b529b3..9d5000e42427b663dcd2342404e28eb171831e97 100644 (file)
@@ -263,7 +263,7 @@ Called whenever the user presses a key combination that has a
 C<perl:string> action bound to it (see description of the B<keysym>
 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<on_key_press> additionally receives the string rxvt-unicode would
+output, if any, in locale-specific encoding.
 
 subwindow.