*** empty log message ***
authorroot <root>
Wed, 18 Jan 2006 17:49:46 +0000 (17:49 +0000)
committerroot <root>
Wed, 18 Jan 2006 17:49:46 +0000 (17:49 +0000)
Changes
doc/rxvt.7.pod
src/command.C
src/urxvt.pm
src/xpm.C

diff --git a/Changes b/Changes
index b450311..e1a804b 100644 (file)
--- a/Changes
+++ b/Changes
@@ -23,13 +23,16 @@ TODO: distributed clipboard example
           special privileges.
         - perl taint checking disabled, as urxvt no longer runs setuid/setgid
           itself.
-        - new extension example: perl/selection-pastebin, can be used to
+        - new perl extension automove-background that can be used to get
+          the same effect as pseudo-transparency with any pixmap.
+        - new perl extension example: perl/selection-pastebin, can be used to
           e.g. upload the selection to a webserver and generate a url, or
           similar stuff.
        - use the scrollback buffer even when the scroll region doesn't
           span the whole screen, as long as it starts at row 0. Helps
           for programs displaying a status line at the bottom.
        - selection popup now shows selection in dec/hex/oct.
+        - some fixes to xpm offste and scaling code.
         - perl/selection: matching on unicode characters in the selection
           code was O(n²), which equals infinity in some degenerate cases
           :-> Matching is now done on UTF-8, which makes it almost instant.
index 570e00a..4f04709 100644 (file)
@@ -1669,7 +1669,7 @@ B<octet> can be escaped by prefixing it with SYN (0x16, ^V).
        B<< C<Ps = 17> >>       Change colour of highlight characters to B<< C<Pt> >>
        B<< C<Ps = 18> >>       Change colour of bold characters to B<< C<Pt> >> [deprecated, see 706]
        B<< C<Ps = 19> >>       Change colour of underlined characters to B<< C<Pt> >> [deprecated, see 707]
-       B<< C<Ps = 20> >>       Change default background to B<< C<Pt> >>
+       B<< C<Ps = 20> >>       Change background pixmap parameters (see section XPM) (Compile XPM).
        B<< C<Ps = 39> >>       Change default foreground colour to B<< C<Pt> >>.
        B<< C<Ps = 46> >>       Change Log File to B<< C<Pt> >> I<unimplemented>
        B<< C<Ps = 49> >>       Change default background colour to B<< C<Pt> >>.
index 0a4e46c..954baf2 100644 (file)
@@ -3768,7 +3768,6 @@ rxvt_term::process_color_seq (int report, int color, const char *str, char resp)
 void
 rxvt_term::process_xterm_seq (int op, const char *str, char resp)
 {
-  int changed = 0;
   int color;
   char *buf, *name;
   bool query = str[0] == '?' && !str[1];
@@ -3894,30 +3893,34 @@ rxvt_term::process_xterm_seq (int op, const char *str, char resp)
 #endif
 
       case Rxvt_Pixmap:
-        if (*str != ';')
-          {
+        {
+          if (*str != ';')
+            {
 #if XPM_BACKGROUND
-            scale_pixmap (""); /* reset to default scaling */
-            set_bgPixmap (str);        /* change pixmap */
-            scr_touch (true);
+              scale_pixmap ("");       /* reset to default scaling */
+              set_bgPixmap (str);      /* change pixmap */
+              scr_touch (true);
 #endif
-          }
+            }
 
-        while ((str = strchr (str, ';')) != NULL)
-          {
-            str++;
+          int changed = 0;
+
+          while ((str = strchr (str, ';')) != NULL)
+            {
+              str++;
 #if XPM_BACKGROUND
-            changed += scale_pixmap (str);
+              changed += scale_pixmap (str);
 #endif
-          }
+            }
 
-        if (changed)
-          {
+          if (changed)
+            {
 #ifdef XPM_BACKGROUND
-            resize_pixmap ();
-            scr_touch (true);
+              resize_pixmap ();
+              scr_touch (true);
 #endif
-          }
+            }
+        }
         break;
 
       case Rxvt_restoreFG:
index a88ce40..6102082 100644 (file)
@@ -166,6 +166,14 @@ make them clickable. When middle-clicked, the program specified in the
 resource C<urlLauncher> (default C<x-www-browser>) will be started with
 the URL as first argument.
 
+=item automove-background
+
+This is basically a one-line extension that dynamically changes the background pixmap offset
+to the window position, in effect creating the same effect as pseudo transparency with
+a custom pixmap. No scaling is supported in this mode. Exmaple:
+
+   @@RXVT_NAME@@ -pixmap background.xpm -pe automove-background
+
 =item block-graphics-to-ascii
 
 A not very useful example of filtering all text output to the terminal,
index 763b9ad..c0fe5fc 100644 (file)
--- a/src/xpm.C
+++ b/src/xpm.C
@@ -52,30 +52,32 @@ static void      rxvt_pixmap_incr                 (unsigned int *wh, unsigned in
 int
 rxvt_term::scale_pixmap (const char *geom)
 {
-  int             flags, changed = 0;
-  int             x = 0, y = 0;
-  unsigned int    w = 0, h = 0;
-  unsigned int    n;
-  char           *p, *str;
-  bgPixmap_t     *bgpixmap = & (bgPixmap);
+  int flags, changed = 0;
+  int x = 0, y = 0;
+  unsigned int w = 0, h = 0;
+  unsigned int n;
+  char *p;
+  bgPixmap_t *bgpixmap = & (bgPixmap);
 
-#define MAXLEN_GEOM            sizeof("[1000x1000+1000+1000]")
+#define MAXLEN_GEOM            sizeof("[10000x10000+10000+10000]")
 
   if (geom == NULL)
     return 0;
-  str = (char *)rxvt_malloc (MAXLEN_GEOM + 1);
+
+  char str[MAXLEN_GEOM];
+
   if (!strcmp (geom, "?"))
     {
       sprintf (str, "[%dx%d+%d+%d]",   /* can't presume snprintf () ! */
-              min (bgpixmap->w, 9999), min (bgpixmap->h, 9999),
-              min (bgpixmap->x, 9999), min (bgpixmap->y, 9999));
+              min (bgpixmap->w, 32767), min (bgpixmap->h, 32767),
+              min (bgpixmap->x, 32767), min (bgpixmap->y, 32767));
       process_xterm_seq (XTerm_title, str, CHAR_ST);
-      free (str);
       return 0;
     }
 
   if ((p = strchr (geom, ';')) == NULL)
     p = strchr (geom, '\0');
+
   n = (p - geom);
   if (n <= MAXLEN_GEOM)
     {
@@ -83,17 +85,21 @@ rxvt_term::scale_pixmap (const char *geom)
       str[n] = '\0';
 
       flags = XParseGeometry (str, &x, &y, &w, &h);
+
       if (!flags)
         {
           flags |= WidthValue;
           w = 0;
         }                      /* default is tile */
+
       if (flags & WidthValue)
         {
-          if (! (flags & XValue))
+          if (!(flags & XValue))
             x = 50;
-          if (! (flags & HeightValue))
+
+          if (!(flags & HeightValue))
             h = w;
+
           if (w && !h)
             {
               w = (bgpixmap->w * w) / 100;
@@ -104,56 +110,56 @@ rxvt_term::scale_pixmap (const char *geom)
               w = bgpixmap->w;
               h = (bgpixmap->h * h) / 100;
             }
-          if (w > 1000)
-            w = 1000;
-          if (h > 1000)
-            h = 1000;
+
+          min_it (w, 32767);
+          min_it (h, 32767);
+
           if (bgpixmap->w != (short)w)
             {
               bgpixmap->w = (short)w;
               changed++;
             }
+
           if (bgpixmap->h != (short)h)
             {
               bgpixmap->h = (short)h;
               changed++;
             }
         }
-      if (! (flags & YValue))
+
+      if (!(flags & YValue))
         {
           if (flags & XNegative)
             flags |= YNegative;
+
           y = x;
         }
 
-      if (! (flags & WidthValue) && geom[0] != '=')
+      if (!(flags & WidthValue) && geom[0] != '=')
         {
           x += bgpixmap->x;
           y += bgpixmap->y;
         }
-      else
+
+      if (xpmAttr.width && xpmAttr.height)
         {
-          if (flags & XNegative)
-            x += 100;
-          if (flags & YNegative)
-            y += 100;
+          x = MOD(x, xpmAttr.width);
+          y = MOD(y, xpmAttr.height);
         }
-      min_it (x, 100);
-      min_it (y, 100);
-      max_it (x, 0);
-      max_it (y, 0);
+
       if (bgpixmap->x != x)
         {
           bgpixmap->x = x;
           changed++;
         }
+
       if (bgpixmap->y != y)
         {
           bgpixmap->y = y;
           changed++;
         }
     }
-  free (str);
+
   return changed;
 }
 
@@ -182,27 +188,29 @@ rxvt_term::resize_pixmap ()
 
   if (bgPixmap.pixmap != None)
     {  /* we have a specified pixmap */
-      unsigned int    w = bgPixmap.w, h = bgPixmap.h,
-                      x = bgPixmap.x, y = bgPixmap.y;
-      unsigned int    xpmh = xpmAttr.height,
-                      xpmw = xpmAttr.width;
+      unsigned int w = bgPixmap.w, h = bgPixmap.h,
+                   x = bgPixmap.x, y = bgPixmap.y;
+      unsigned int xpmh = xpmAttr.height,
+                   xpmw = xpmAttr.width;
 
       /*
        * don't zoom pixmap too much nor expand really small pixmaps
        */
-      if (w > 1000 || h > 1000)
+      if (w > 32767 || h > 32767)
         w = 1;
       else if (width > (10 * xpmw)
                || height > (10 * xpmh))
         w = 0;         /* tile */
 
-      if (w == 0)
+      if (!w)
         {
           /* basic X tiling - let the X server do it */
-          pixmap = XCreatePixmap (disp, vt, xpmw, xpmh,
-                                  (unsigned int)display->depth);
-          XCopyArea (disp, bgPixmap.pixmap, pixmap, gc,
-                     0, 0, xpmw, xpmh, 0, 0);
+          pixmap = XCreatePixmap (disp, vt, xpmw, xpmh, display->depth);
+
+          XCopyArea (disp, bgPixmap.pixmap, pixmap, gc, x, y, xpmw - x, xpmh - y,        0,        0);
+          XCopyArea (disp, bgPixmap.pixmap, pixmap, gc, x, 0, xpmw - x,        y,        0, xpmh - y);
+          XCopyArea (disp, bgPixmap.pixmap, pixmap, gc, 0, y,        x, xpmh - y, xpmw - x,        0);
+          XCopyArea (disp, bgPixmap.pixmap, pixmap, gc, 0, 0,        x,        y, xpmw - x, xpmh - y);
         }
       else
         {
@@ -223,6 +231,7 @@ rxvt_term::resize_pixmap ()
             {
               if (p >= xpmw)
                 p = 0;
+
               /* copy one column from the original pixmap to the tmp pixmap */
               XCopyArea (disp, bgPixmap.pixmap, tmp, gc,
                         (int)p, 0, 1, xpmh, (int)x, 0);
@@ -254,6 +263,13 @@ rxvt_term::resize_pixmap ()
     }
 
   XSetWindowBackgroundPixmap (disp, vt, pixmap);
+
+  if (pixmap != None)
+    {
+      XFreePixmap (disp, pixmap);
+      pixmap = None;
+    }
+
   XFreeGC (disp, gc);
   am_transparent = 0;
 }