*** empty log message ***
authorroot <root>
Fri, 13 Jan 2006 04:59:04 +0000 (04:59 +0000)
committerroot <root>
Fri, 13 Jan 2006 04:59:04 +0000 (04:59 +0000)
src/command.C
src/hookinc.h
src/init.C
src/rxvt.h
src/rxvtperl.h
src/rxvtperl.xs
src/rxvttoolkit.h
src/urxvt.pm

index 2f90882..d2eb851 100644 (file)
@@ -1313,6 +1313,10 @@ rxvt_term::x_cb (XEvent &ev)
   SET_R (this);
   SET_LOCALE (locale);
 
+  if (ev.xany.window == vt
+      && HOOK_INVOKE ((this, HOOK_X_EVENT, DT_XEVENT, &ev, DT_END)))
+    return;
+
   Window unused_root, unused_child;
   int unused_root_x, unused_root_y;
   unsigned int unused_mask;
@@ -1602,6 +1606,7 @@ rxvt_term::x_cb (XEvent &ev)
         break;
 
       case MotionNotify:
+        printf ("motion notify\n");//D
 #ifdef POINTER_BLANK
         if (hidden_pointer)
           pointer_unblank ();
index c158c71..18d1ca4 100644 (file)
@@ -24,6 +24,7 @@
 
   def (KEYBOARD_COMMAND)
 
+  def (X_EVENT)
   def (FOCUS_IN)
   def (FOCUS_OUT)
   def (KEY_PRESS)
@@ -33,4 +34,4 @@
   def (MOTION_NOTIFY)
   def (MAP_NOTIFY)
   def (UNMAP_NOTIFY)
-  def (ON_CUSTOM_REND) // hovering over custom rendition, generate enter/leave maybe?
+  def (CUSTOM_REND) // hovering over custom rendition, generate enter/leave maybe?
index c763bf9..29a6e24 100644 (file)
@@ -1096,16 +1096,13 @@ rxvt_term::create_windows (int argc, const char *const *argv)
 
   vt_emask = ExposureMask | ButtonPressMask | ButtonReleaseMask | PropertyChangeMask;
 
-  if (OPTION (Opt_pointerBlank)
-#ifdef ENABLE_PERL
-      || perl.self
-#endif
-      )
+  if (OPTION (Opt_pointerBlank))
     vt_emask |= PointerMotionMask;
   else
     vt_emask |= Button1MotionMask | Button3MotionMask;
 
-  XSelectInput (disp, vt, vt_emask);
+  vt_select_input ();
+
   vt_ev.start (display, vt);
 
 #if defined(MENUBAR) && (MENUBAR_MAX > 1)
index a0e6bf6..d9c9b96 100644 (file)
@@ -1210,8 +1210,12 @@ struct rxvt_term : zero_initialized, rxvt_vars {
   // modifies first argument(!)
   void paste (char *data, unsigned int len);
 
-  long vt_emask;
-  void flush ();
+  long vt_emask, vt_emask_perl;
+
+  void vt_select_input ()
+  {
+    XSelectInput (display->display, vt, vt_emask | vt_emask_perl);
+  }
 
 #if TRANSPARENT
   void rootwin_cb (XEvent &xev);
@@ -1219,6 +1223,7 @@ struct rxvt_term : zero_initialized, rxvt_vars {
 #endif
 
   void x_cb (XEvent &xev);
+  void flush ();
   xevent_watcher termwin_ev;
   xevent_watcher vt_ev;
 #ifdef HAVE_SCROLLBARS
index 75f90dd..a180ce3 100644 (file)
@@ -6,7 +6,7 @@
 #define RXVTPERL_H_
 
 #if ENABLE_PERL
-# define SHOULD_INVOKE(htype) rxvt_perl.should_invoke [htype]
+# define SHOULD_INVOKE(htype) perl.should_invoke [htype]
 # define HOOK_INVOKE(args) rxvt_perl.invoke args
 
 #include "rxvt.h"
@@ -32,6 +32,7 @@ struct rxvt_perl_term
 {
   void *self;
   unsigned long grabtime;
+  uint8_t should_invoke[HOOK_NUM];
 };
 
 struct rxvt_perl_interp
@@ -40,8 +41,6 @@ struct rxvt_perl_interp
 
   ~rxvt_perl_interp ();
 
-  bool should_invoke[HOOK_NUM];
-
   void init ();
   bool invoke (rxvt_term *term, hook_type htype, ...);
   void line_update (rxvt_term *term);
index 20d6f07..10883c6 100644 (file)
@@ -481,7 +481,7 @@ rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...)
 
         }
 
-      if (!should_invoke [htype])
+      if (!term->perl.should_invoke [htype])
         return false;
     }
 
@@ -661,42 +661,107 @@ BOOT:
 # undef def
 
   HV *stash = gv_stashpv ("urxvt", 1);
-# define export_const_iv(name) newCONSTSUB (stash, # name, newSViv (name));
-  export_const_iv (DEFAULT_RSTYLE);
-  export_const_iv (OVERLAY_RSTYLE);
-  export_const_iv (RS_Bold);
-  export_const_iv (RS_Italic);
-  export_const_iv (RS_Blink);
-  export_const_iv (RS_RVid);
-  export_const_iv (RS_Uline);
-
-  export_const_iv (CurrentTime);
-  export_const_iv (ShiftMask);
-  export_const_iv (LockMask);
-  export_const_iv (ControlMask);
-  export_const_iv (Mod1Mask);
-  export_const_iv (Mod2Mask);
-  export_const_iv (Mod3Mask);
-  export_const_iv (Mod4Mask);
-  export_const_iv (Mod5Mask);
-  export_const_iv (Button1Mask);
-  export_const_iv (Button2Mask);
-  export_const_iv (Button3Mask);
-  export_const_iv (Button4Mask);
-  export_const_iv (Button5Mask);
-  export_const_iv (AnyModifier);
-
-  export_const_iv (EVENT_NONE);
-  export_const_iv (EVENT_READ);
-  export_const_iv (EVENT_WRITE);
+  struct {
+    const char *name;
+    IV iv;
+  } *civ, const_iv[] = {
+#   define const_iv(name) { # name, (IV)name }
+    const_iv (DEFAULT_RSTYLE),
+    const_iv (OVERLAY_RSTYLE),
+    const_iv (RS_Bold),
+    const_iv (RS_Italic),
+    const_iv (RS_Blink),
+    const_iv (RS_RVid),
+    const_iv (RS_Uline),
+
+    const_iv (CurrentTime),
+    const_iv (ShiftMask),
+    const_iv (LockMask),
+    const_iv (ControlMask),
+    const_iv (Mod1Mask),
+    const_iv (Mod2Mask),
+    const_iv (Mod3Mask),
+    const_iv (Mod4Mask),
+    const_iv (Mod5Mask),
+    const_iv (Button1Mask),
+    const_iv (Button2Mask),
+    const_iv (Button3Mask),
+    const_iv (Button4Mask),
+    const_iv (Button5Mask),
+    const_iv (AnyModifier),
+
+    const_iv (EVENT_NONE),
+    const_iv (EVENT_READ),
+    const_iv (EVENT_WRITE),
+
+    const_iv (NoEventMask),
+    const_iv (KeyPressMask),
+    const_iv (KeyReleaseMask),
+    const_iv (ButtonPressMask),
+    const_iv (ButtonReleaseMask),
+    const_iv (EnterWindowMask),
+    const_iv (LeaveWindowMask),
+    const_iv (PointerMotionMask),
+    const_iv (PointerMotionHintMask),
+    const_iv (Button1MotionMask),
+    const_iv (Button2MotionMask),
+    const_iv (Button3MotionMask),
+    const_iv (Button4MotionMask),
+    const_iv (Button5MotionMask),
+    const_iv (ButtonMotionMask),
+    const_iv (KeymapStateMask),
+    const_iv (ExposureMask),
+    const_iv (VisibilityChangeMask),
+    const_iv (StructureNotifyMask),
+    const_iv (ResizeRedirectMask),
+    const_iv (SubstructureNotifyMask),
+    const_iv (SubstructureRedirectMask),
+    const_iv (FocusChangeMask),
+    const_iv (PropertyChangeMask),
+    const_iv (ColormapChangeMask),
+    const_iv (OwnerGrabButtonMask),
+
+    const_iv (KeyPress),
+    const_iv (KeyRelease),
+    const_iv (ButtonPress),
+    const_iv (ButtonRelease),
+    const_iv (MotionNotify),
+    const_iv (EnterNotify),
+    const_iv (LeaveNotify),
+    const_iv (FocusIn),
+    const_iv (FocusOut),
+    const_iv (KeymapNotify),
+    const_iv (Expose),
+    const_iv (GraphicsExpose),
+    const_iv (NoExpose),
+    const_iv (VisibilityNotify),
+    const_iv (CreateNotify),
+    const_iv (DestroyNotify),
+    const_iv (UnmapNotify),
+    const_iv (MapNotify),
+    const_iv (MapRequest),
+    const_iv (ReparentNotify),
+    const_iv (ConfigureNotify),
+    const_iv (ConfigureRequest),
+    const_iv (GravityNotify),
+    const_iv (ResizeRequest),
+    const_iv (CirculateNotify),
+    const_iv (CirculateRequest),
+    const_iv (PropertyNotify),
+    const_iv (SelectionClear),
+    const_iv (SelectionRequest),
+    const_iv (SelectionNotify),
+    const_iv (ColormapNotify),
+    const_iv (ClientMessage),
+    const_iv (MappingNotify),
+  };
+
+  for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]);
+       civ-- > const_iv; )
+    newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv));
 }
 
 void
-set_should_invoke (int htype, int value)
-       CODE:
-        rxvt_perl.should_invoke [htype] = value;
-
-void
 warn (const char *msg)
        CODE:
         rxvt_warn ("%s", msg);
@@ -829,6 +894,11 @@ void
 rxvt_term::destroy ()
 
 void
+rxvt_term::set_should_invoke (int htype, int inc)
+       CODE:
+        THIS->perl.should_invoke [htype] += inc;
+
+void
 rxvt_term::grab_button (int button, U32 modifiers)
        CODE:
        XGrabButton (THIS->display->display, button, modifiers, THIS->vt, 1,
@@ -1035,6 +1105,12 @@ rxvt_term::vt ()
         OUTPUT:
         RETVAL
 
+void
+rxvt_term::vt_emask_add (U32 emask)
+       CODE:
+        THIS->vt_emask_perl |= emask;
+        THIS->vt_select_input ();
+
 U32
 rxvt_term::rstyle (U32 new_rstyle = THIS->rstyle)
        CODE:
index 4d6eb58..88aa46e 100644 (file)
@@ -97,8 +97,6 @@ struct rxvt_display : refcounted {
   void ref_next ();
   ~rxvt_display ();
 
-  operator Display *() const { return display; }
-
   void flush ();
   Atom atom (const char *name);
   void set_selection_owner (rxvt_term *owner);
index f43bbd3..e8f046c 100644 (file)
@@ -373,6 +373,12 @@ 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_x_event $term, $event
+
+Called on every X event received on the vt window (and possibly other
+windows). Should only be used as a last resort. Most event structure
+members are not passed.
+
 =item on_focus_in $term
 
 Called whenever the window gets the keyboard focus, before rxvt-unicode
@@ -493,6 +499,22 @@ Returns the "current time" (as per the event loop).
 Mod3Mask, Mod4Mask, Mod5Mask, Button1Mask, Button2Mask, Button3Mask,
 Button4Mask, Button5Mask, AnyModifier
 
+=item urxvt::NoEventMask, KeyPressMask, KeyReleaseMask,
+ButtonPressMask, ButtonReleaseMask, EnterWindowMask, LeaveWindowMask,
+PointerMotionMask, PointerMotionHintMask, Button1MotionMask, Button2MotionMask,
+Button3MotionMask, Button4MotionMask, Button5MotionMask, ButtonMotionMask,
+KeymapStateMask, ExposureMask, VisibilityChangeMask, StructureNotifyMask,
+ResizeRedirectMask, SubstructureNotifyMask, SubstructureRedirectMask,
+FocusChangeMask, PropertyChangeMask, ColormapChangeMask, OwnerGrabButtonMask
+
+=item urxvt::KeyPress, KeyRelease, ButtonPress, ButtonRelease, MotionNotify,
+EnterNotify, LeaveNotify, FocusIn, FocusOut, KeymapNotify, Expose,
+GraphicsExpose, NoExpose, VisibilityNotify, CreateNotify, DestroyNotify,
+UnmapNotify, MapNotify, MapRequest, ReparentNotify, ConfigureNotify,
+ConfigureRequest, GravityNotify, ResizeRequest, CirculateNotify,
+CirculateRequest, PropertyNotify, SelectionClear, SelectionRequest,
+SelectionNotify, ColormapNotify, ClientMessage, MappingNotify
+
 Various constants for use in X calls and event processing.
 
 =back
@@ -569,7 +591,6 @@ BEGIN {
    $ENV{PATH} = "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/opt/bin:/opt/sbin";
 }
 
-my @hook_count;
 my $verbosity = $ENV{URXVT_PERL_VERBOSITY};
 
 sub verbose {
@@ -667,13 +688,6 @@ sub invoke {
    }
 
    if ($htype == 1) { # DESTROY
-      if (my $hook = delete $TERM->{_hook}) {
-         for my $htype (0..$#$hook) {
-            $hook_count[$htype] -= scalar keys %{ $hook->[$htype] || {} }
-               or set_should_invoke $htype, 0;
-         }
-      }
-
       # clear package objects
       %$_ = () for values %{ $TERM->{_pkg} };
 
@@ -709,10 +723,8 @@ sub enable {
       defined $htype
          or Carp::croak "unsupported hook type '$name'";
 
-      unless (exists $self->{term}{_hook}[$htype]{$pkg}) {
-         $hook_count[$htype]++
-            or urxvt::set_should_invoke $htype, 1;
-      }
+      $self->set_should_invoke ($htype, +1)
+         unless exists $self->{term}{_hook}[$htype]{$pkg};
 
       $self->{term}{_hook}[$htype]{$pkg} = $cb;
    }
@@ -727,10 +739,8 @@ sub disable {
       defined $htype
          or Carp::croak "unsupported hook type '$name'";
 
-      if (delete $self->{term}{_hook}[$htype]{$pkg}) {
-         --$hook_count[$htype]
-            or urxvt::set_should_invoke $htype, 0;
-      }
+      $self->set_should_invoke ($htype, -1)
+         if delete $self->{term}{_hook}[$htype]{$pkg};
    }
 }
 
@@ -1145,6 +1155,13 @@ Return the window id of the toplevel window.
 
 Return the window id of the terminal window.
 
+=item $term->vt_emask_add ($x_event_mask)
+
+Adds the specified events to the vt event mask. Useful e.g. when you want
+to receive pointer events all the times:
+
+   $term->vt_emask_add (urxvt::PointerMotionMask);
+
 =item $window_width = $term->width
 
 =item $window_height = $term->height