-- Leo's gemini proxy

-- Connecting to git.thebackupbox.net:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini

repo: rxvt-unicode-sixel
action: commit
revision:
path_from:
revision_from: dee7978ecb4519faed5156d56877f116046c0dd7:
path_to:
revision_to:

git.thebackupbox.net

rxvt-unicode-sixel

git://git.thebackupbox.net/rxvt-unicode-sixel

commit dee7978ecb4519faed5156d56877f116046c0dd7
Author: Sasha Vasko <sashavasko@gmail.com>
Date:   Fri Jun 8 20:04:12 2007 +0000

    added preliminary support to use libAfterImage for background pixmap loading and rendering of transparency effects including blending of pixmap over background using several methods, and gaussian blurr of the transparency background

diff --git a/Makefile.in b/Makefile.in

index 4bd8d4f3e3d15a65e6f3e9a69b28573525f1025a..

index ..932dfd300f22c4359b857b795a97a875d1eb8df6 100644

--- a/Makefile.in
+++ b/Makefile.in
@@ -112,10 +112,10 @@ cleandir: realclean
 # In that case most of those commands do nothing, except cleaning *~
 # and cleaning source links.
 distclean:
-	(cd $(srcdir); rm -f *~ config.cache config.h config.log config.status libtool)
-	@for I in $(allsubdirs); do (cd $$I; $(MAKE) $@) || exit 1; done
-	(cd $(srcdir); rm -f Makefile)
-
+	(cd $(srcdir); rm -f *~ config.cache config.h config.log config.status libtool rxvtlib.h)
+	@for I in $(allsubdirs); do (cd $$I; $(MAKE) $@; rm -f Makefile) || exit 1; done
+	rm -f Makefile
+
 distdir:
 	cd doc && $(MAKE) distdepend
 	cd src && $(MAKE) depend
diff --git a/config.h.in b/config.h.in

index 674f175934a6012f99cdbe18f7ec236326107c18..

index ..202fceb266d30b577373bfd14b9ef7661bac1988 100644

--- a/config.h.in
+++ b/config.h.in
@@ -1,5 +1,8 @@
 /* config.h.in.  Generated from configure.ac by autoheader.  */

+/* Define if you want to integrate with AfterStep window manager */
+#undef AFTERSTEP_INTEGRATION
+
 /* clone device filename */
 #undef CLONE_DEVICE

@@ -39,6 +42,9 @@
 /* Define if you want extended chinese codesets */
 #undef ENCODING_ZH_EXT

+/* Define if you want to use libAfterImage for image processing */
+#undef HAVE_AFTERIMAGE
+
 /* Define to 1 if you have the <assert.h> header file. */
 #undef HAVE_ASSERT_H

@@ -405,7 +411,8 @@
 /* Define ONLY iff Xlib.h supports it */
 #undef XLIB_ILLEGAL_ACCESS

-/* Define if you want to have sexy-looking background pixmaps. Needs libXpm */
+/* Define if you want to have sexy-looking background pixmaps. Needs libXpm or
+   libAfterImage */
 #undef XPM_BACKGROUND

 /* Define if you include <X11/xpm.h> on a normal include path (be careful) */
diff --git a/configure.ac b/configure.ac

index 9934fd2a001540b37a24175fc3137a21e10a5623..

index ..370edf8fe0241b5b56eee6cae0ffeffc195de6f3 100644

--- a/configure.ac
+++ b/configure.ac
@@ -113,6 +113,8 @@ support_scroll_xterm=yes
 support_scroll_plain=yes
 support_xim=yes
 support_xpm=yes
+support_afterimage=yes
+support_afterstep=yes
 support_xft=yes
 support_unicode3=no
 support_combining=yes
@@ -157,6 +159,8 @@ AC_ARG_ENABLE(everything,
        support_wtmp=no
        support_xim=no
        support_xpm=no
+       support_afterimage=no
+       support_afterstep=no
        support_xft=no
        support_unicode3=no
        support_combining=no
@@ -186,6 +190,8 @@ AC_ARG_ENABLE(everything,
        support_wtmp=yes
        support_xim=yes
        support_xpm=yes
+       support_afterimage=yes
+       support_afterstep=yes
        support_xft=yes
        support_unicode3=yes
        support_combining=yes
@@ -222,11 +228,25 @@ AC_ARG_ENABLE(font-styles,
   fi])

 AC_ARG_ENABLE(xpm-background,
-  [  --enable-xpm-background enable XPM background pixmaps],
+  [  --enable-xpm-background enable background pixmaps],
   [if test x$enableval = xyes -o x$enableval = xno; then
     support_xpm=$enableval
   fi])

+AC_ARG_ENABLE(afterimage,
+  [  --enable-afterimage enable integration with libAfterImage for background images],
+  [if test x$enableval = xyes -o x$enableval = xno; then
+    support_afterimage=$enableval
+  fi])
+
+AC_ARG_WITH(afterimage_config,  [  --with-afterimage-config=DIR  use libAfterImage config script in DIR], afterimage_config="$withval",afterimage_config=NO)
+
+AC_ARG_ENABLE(afterstep,
+  [  --enable-afterstep enable integration with AfterStep window manager],
+  [if test x$enableval = xyes -o x$enableval = xno; then
+    support_afterstep=$enableval
+  fi])
+
 AC_ARG_ENABLE(transparency,
   [  --enable-transparency   enable transparent backgrounds],
   [if test x$enableval = xyes -o x$enableval = xno; then
@@ -443,7 +463,40 @@ AC_PATH_XTRA
 dnl# the only reasonable way to find libXpm is do-it-yourself
 dnl# only check if we want xpm-background

-if test x$support_xpm = xyes; then
+LIBAFTERIMAGE_CFLAGS=
+AFTERIMAGE_LIBS=
+have_afterimage=
+
+if test x$support_afterimage == xyes; then
+	AC_MSG_CHECKING(installed libAfterImage)
+	support_afterimage=no
+	if test "$afterimage_config" = "NO" ; then
+		if afterimage-config --version > /dev/null 2>&1 ; then
+			afterimage_config=afterimage-config
+		else
+			if test -x /usr/local/bin/afterimage-config; then
+				afterimage_config=/usr/local/bin/afterimage-config
+			fi
+		fi
+	else
+	    afterimage_config=$afterimage_config/afterimage-config
+	fi
+	if $afterimage_config --version > /dev/null 2>&1 ; then
+		LIBAFTERIMAGE_CFLAGS=`$afterimage_config --cflags`
+		AFTERIMAGE_LIBS=`$afterimage_config --libs`
+		if test "x$AFTERIMAGE_LIBS" != "x"; then
+			support_afterimage=yes
+		fi
+	fi
+
+	if test "x$support_afterimage" = "xyes"; then
+		AC_MSG_RESULT($AFTERIMAGE_LIBS)
+	else
+		AC_MSG_RESULT(afterimage-config not found in $afterimage_config - can't use libAfterImage for images.)
+	fi
+fi
+
+if test x$support_afterimage != xyes -a x$support_xpm = xyes ; then
   VT_FIND_LIBXPM
   if test x$no_xpm = xyes; then
     support_xpm=needsmanualspecification
@@ -805,9 +858,18 @@ if test x$support_xim = xyes -o x$multichar_set = xyes; then
     AC_DEFINE(USE_XIM, 1, Define if you want to have XIM (X Input Method) protocol support - required for multibyte characters input)
   fi
 fi
-if test x$support_xpm = xyes; then
-  AC_DEFINE(XPM_BACKGROUND, 1, Define if you want to have sexy-looking background pixmaps. Needs libXpm)
+if test x$support_xpm = xyes -o x$support_afterimage = xyes ; then
+  AC_DEFINE(XPM_BACKGROUND, 1, Define if you want to have sexy-looking background pixmaps. Needs libXpm or libAfterImage)
 fi
+
+if test x$support_afterimage = xyes; then
+  AC_DEFINE(HAVE_AFTERIMAGE, 1, Define if you want to use libAfterImage for image processing)
+fi
+
+if test x$support_afterstep = xyes; then
+  AC_DEFINE(AFTERSTEP_INTEGRATION, 1, Define if you want to integrate with AfterStep window manager)
+fi
+
 if test x$support_scroll_rxvt = xyes; then
   AC_DEFINE(RXVT_SCROLLBAR, 1, Support Rxvt original style scrollbars)
   scrolltypes="rxvt"
@@ -919,6 +981,9 @@ AC_SUBST(LIBS)
 AC_SUBST(X_LIBS)
 AC_SUBST(X_EXTRA_LIBS)

+AC_SUBST(LIBAFTERIMAGE_CFLAGS)
+AC_SUBST(AFTERIMAGE_LIBS)
+
 AC_ARG_PROGRAM

 dnl# test for "sun" or "__sun__" before include sys_ioctl
@@ -966,6 +1031,14 @@ if test x$support_xpm = xyes; then
   echo "  Xpm library:                $XPM_LIBS"
 fi

+if test x$support_afterimage = xyes; then
+  echo "  AfterImage library:                $AFTERIMAGE_LIBS"
+fi
+
+if test x$support_afterstep = xyes; then
+  echo "  With AfterStep integration"
+fi
+
 if test x$term != x; then
   echo "  set TERM to:                $term"
 fi
diff --git a/doc/rxvt.1.pod b/doc/rxvt.1.pod

index c5579700be036ad6869e91170db2c659c84cf75a..

index ..ecb6d9b6b7a285e862de5cf8610b9a45bdc52d75 100644

--- a/doc/rxvt.1.pod
+++ b/doc/rxvt.1.pod
@@ -142,11 +142,26 @@ I<tintColor>. Example:

    @@RXVT_NAME@@ -tr -tint blue -sh 40

-=item B<-sh>
+=item B<-sh> I<number>

-I<number> Darken (0 .. 100) or lighten (-1 .. -100) the transparent
-background image in addition to tinting it (i.e. B<-tint> must be
-specified, too, e.g. C<-tint white>); resource I<shading>.
+Darken (0 .. 100) or lighten (-1 .. -100) the transparent
+background image in addition to (or instead of) tinting it;
+resource I<shading>.
+
+=item B<-blt> I<string>
+
+Specify background blending type. If background pixmap is specified
+at the same time as transparency - such pixmap will be blended over
+transparency image, using method specified. Supported values are :
+B<add>, B<alphablend>, B<allanon> - color values averaging, B<colorize>,
+B<darken>, B<diff>, B<dissipate>, B<hue>, B<lighten>, B<overlay>,
+B<saturate>, B<screen>, B<sub>, B<tint>, B<value>. The default is
+alpha-blending; resource I<blendType>.
+
+=item B<-blr> I<number>
+
+Apply Gaussian Blur with the specified radius to the transparent
+background image; resource I<blurRadius>.

 =item B<-bg> I<colour>

@@ -158,10 +173,10 @@ Window foreground colour; resource B<foreground>.

 =item B<-pixmap> I<file[;geom]>

-Compile I<XPM>: Specify XPM file for the background and also optionally
-specify its scaling with a geometry string. Note you may need to
+Compile I<afterimage>: Specify image file for the background and also
+optionally specify its scaling with a geometry string. Note you may need to
 add quotes to avoid special shell interpretation of the C<;> in the
-command-line; resource B<backgroundPixmap>.
+command-line; for more details see resource B<backgroundPixmap>.

 =item B<-cr> I<colour>

@@ -626,6 +641,15 @@ B<-tint>.
 Darken (0 .. 100) or lighten (-1 .. -100) the transparent background image
 in addition to tinting it; option B<-sh>.

+=item B<blendType:> I<string>
+
+Specify background blending type; option B<-blt>.
+
+=item B<blurRadius:> I<number>
+
+Apply Gaussian Blurr with the specified radius to the transparent
+background image; option B<-blr>.
+
 =item B<scrollColor:> I<colour>

 Use the specified colour for the scrollbar [default #B2B2B2].
@@ -642,15 +666,20 @@ and the text.

 =item B<backgroundPixmap:> I<file[;geom]>

-Use the specified XPM file (note the `.xpm' extension is optional) for
-the background and also optionally specify its scaling with a geometry
-string B<WxH+X+Y>, in which B<"W" / "H"> specify the
-horizontal/vertical scale (percent) and B<"X" / "Y"> locate the image
-centre (percent). A scale of 0 displays the image with tiling. A scale
-of 1 displays the image without any scaling. A scale of 2 to 9
-specifies an integer number of images in that direction. No image will
-be magnified beyond 10 times its original size. The maximum permitted
-scale is 1000. [default 0x0+50+50]
+Use the specified image file for the background and also optionally
+specify its scaling with a geometry string B<WxH+X+Y>,
+in which B<"W" / "H"> specify the horizontal/vertical scale (percent),
+and B<"X" / "Y"> locate the image centre (percent).
+A scale of 0 displays the image with tiling. A scale of 1 displays the
+image without any scaling. A scale of 2 to 9 specifies an integer
+number of images in that direction. No image will be magnified beyond
+10 times its original size. The maximum permitted scale is 1000.
+Special string of B<"auto"> used as a geometry will cause image to be
+automatically scaled to match window size.
+If used in conjunction with B<-tr> option - specified pixmap will be
+blended over transparency image using either alpha-blending, or any
+other blending type, specified with B<-blt "type"> option.
+[default 0x0+50+50]

 =item B<path:> I<path>

diff --git a/src/Makefile.in b/src/Makefile.in

index 6f5d8c112cc904a9a486874666b198c1244a83bd..

index ..688b8837aca29391fcdd7a40a3f95c6759091b0f 100644

--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -26,8 +26,8 @@ DEFS = @DEFS@
 LIBS = @LIBS@
 DINCLUDE = @DINCLUDE@
 DLIB = @DLIB@
-XINC = @X_CFLAGS@ @XPM_CFLAGS@
-XLIB = @X_LIBS@ @XPM_LIBS@ -lX11 @X_EXTRA_LIBS@
+XINC = @X_CFLAGS@ @XPM_CFLAGS@  @LIBAFTERIMAGE_CFLAGS@
+XLIB = @X_LIBS@ @XPM_LIBS@  @AFTERIMAGE_LIBS@ -lX11 @X_EXTRA_LIBS@
 COMPILE = $(CXX) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CXXFLAGS) $(DEBUG) $(DINCLUDE) $(XINC) -I$(basedir) -I$(srcdir) -I.
 LINK = @LINKER@ $(LDFLAGS)

diff --git a/src/command.C b/src/command.C

index 90afe29fce0f2721e877855ab200696bb448cd85..

index ..4d71cc58393bd147e15e25fa9376c38c1a2f993f 100644

--- a/src/command.C
+++ b/src/command.C
@@ -1491,6 +1491,13 @@ rxvt_term::x_cb (XEvent &ev)
               {
                 seen_resize = 1;
                 resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1);
+#ifdef XPM_BACKGROUND
+                if (!option(Opt_transparent) && bgPixmap.auto_resize)
+                  {
+                    resize_pixmap ();
+                    scr_touch (true);
+                  }
+#endif
               }

             HOOK_INVOKE ((this, HOOK_CONFIGURE_NOTIFY, DT_XEVENT, &ev, DT_END));
@@ -1841,8 +1848,8 @@ rxvt_term::rootwin_cb (XEvent &ev)

         /* FALLTHROUGH */
       case ReparentNotify:
-        if (option (Opt_transparent) && check_our_parents () && am_transparent)
-          want_refresh = want_full_refresh = 1;
+        if (option (Opt_transparent))
+          check_our_parents ();
         break;
     }
 # endif
@@ -2230,7 +2237,7 @@ rxvt_term::button_release (XButtonEvent &ev)
 }

 #ifdef TRANSPARENT
-#if TINTING
+#if TINTING && !defined(HAVE_AFTERIMAGE)
 /* taken from aterm-0.4.2 */

 typedef uint32_t RUINT32T;
@@ -2467,6 +2474,16 @@ void ShadeXImage(rxvt_term *term, XImage* srcImage, int shade, int rm, int gm, i
  */
 int
 rxvt_term::check_our_parents ()
+{
+#if TRANSPARENT || ENABLE_PERL
+  check_our_aprents_ev.stop();
+  check_our_aprents_ev.start(NOW + 1./3.);
+#endif
+  return 0;
+}
+
+void
+rxvt_term::check_our_parents_cb (time_watcher &w)
 {
   int i, pchanged, aformat, have_pixmap, rootdepth;
   unsigned long nitems, bytes_after;
@@ -2475,11 +2492,13 @@ rxvt_term::check_our_parents ()
   Window root, oldp, *list;
   Pixmap rootpixmap = None;
   XWindowAttributes wattr, wrootattr;
+  int sx, sy;
+  Window cr;

   pchanged = 0;

   if (!option (Opt_transparent))
-    return pchanged;	/* Don't try any more */
+    return /*pchanged*/;	/* Don't try any more */

   XGetWindowAttributes (dpy, display->root, &wrootattr);
   rootdepth = wrootattr.depth;
@@ -2495,12 +2514,19 @@ rxvt_term::check_our_parents ()
           am_transparent = am_pixmap_trans = 0;
         }

-      return pchanged;	/* Don't try any more */
+      return /*pchanged*/;	/* Don't try any more */
     }

   /* Get all X ops out of the queue so that our information is up-to-date. */
   XSync (dpy, False);

+  XTranslateCoordinates (dpy, parent[0], display->root,
+                          0, 0, &sx, &sy, &cr);
+
+    /* check if we are outside of the visible part of the virtual screen : */
+  if( sx + (int)szHint.width <= 0 || sy + (int)szHint.height <= 0
+      || sx >= wrootattr.width || sy >= wrootattr.height )
+    return /* 0 */ ;
   /*
    * Make the frame window set by the window manager have
    * the root background. Some window managers put multiple nested frame
@@ -2519,7 +2545,11 @@ rxvt_term::check_our_parents ()

   if (!i || prop == NULL
 #if TINTING
-      || !ISSET_PIXCOLOR (Color_tint)
+      || (!ISSET_PIXCOLOR (Color_tint) && rs[Rs_shade] == NULL
+#ifdef HAVE_AFTERIMAGE
+          && original_asim == NULL && rs[Rs_blurradius] == NULL
+#endif
+         )
 #endif
       )
     have_pixmap = 0;
@@ -2532,48 +2562,192 @@ rxvt_term::check_our_parents ()

   if (have_pixmap)
     {
+      Bool success = False ;
+      GC gc;
+      XGCValues gcvalue;
+#ifdef HAVE_AFTERIMAGE
+      {
+        Pixmap tmp_pmap = None ;
+        ShadingInfo shade;
+        ARGB32 tint ;
+        unsigned int pmap_w = 0, pmap_h = 0;
+
+        if (get_drawable_size( rootpixmap, &pmap_w, &pmap_h ))
+          {
+            int root_x = 0, root_y = 0;
+
+  	         shade.shading = rs[Rs_shade] ? atoi (rs[Rs_shade]) : 100;
+            if (ISSET_PIXCOLOR (Color_tint))
+              {
+                rgba c;
+                pix_colors_focused [Color_tint].get (c);
+                shade.tintColor.red = c.r;
+                shade.tintColor.green = c.g;
+                shade.tintColor.blue = c.b;
+              }
+            else
+              shade.tintColor.red = shade.tintColor.green = shade.tintColor.blue = 0xFFFF;
+            tint = shading2tint32( &shade );
+            gc = XCreateGC (dpy, vt, 0UL, &gcvalue);
+            if (GetWinPosition (parent[0], &root_x, &root_y)  )
+              {
+                ASImageLayer *layers = create_image_layers( 2 );
+                ASImage *merged_im = NULL;
+                int back_x, back_y, back_w, back_h;
+                /* merge_layers does good job at tiling background appropriately,
+                   so all we need is to cut out smallest possible piece : */
+#define MAKE_ROOTPMAP_GEOM(xy,wh,widthheight) \
+          do{ while( root_##xy < 0 ) root_##xy += (int)wrootattr.widthheight; \
+                back_##xy = root_##xy % pmap_##wh;   /* that gives us left side of the closest tile : */ \
+                if( pmap_##wh >= back_##xy + szHint.widthheight ) \
+                  back_##wh = szHint.widthheight;/* background is large - limit it by our size */ \
+                else \
+                  { /* small background - need the whole of it for successfull tiling :*/ \
+                    back_##xy = 0; \
+                    back_##wh = pmap_##wh; \
+                  }}while(0)
+
+                MAKE_ROOTPMAP_GEOM(x,w,width);
+                MAKE_ROOTPMAP_GEOM(y,h,height);
+
+                layers[0].im = pixmap2asimage (display->asv, rootpixmap, back_x, back_y, back_w, back_h, AllPlanes, ASA_ASImage, 100);
+                layers[0].clip_x = (back_w == pmap_w)?root_x:0;
+                layers[0].clip_y = (back_h == pmap_h)?root_y:0;
+                layers[0].clip_width = szHint.width;
+                layers[0].clip_height = szHint.height;
+                layers[0].tint = tint;
+                if (rs[Rs_blurradius] && layers[0].im)
+                  {
+                    double r = atof(rs[Rs_blurradius]);
+                    ASImage* tmp = blur_asimage_gauss(display->asv, layers[0].im, r, r, 0xFFFFFFFF, ASA_ASImage, 100, ASIMAGE_QUALITY_DEFAULT );
+                    if( tmp )
+                      {
+                        destroy_asimage( &layers[0].im );
+                        layers[0].im = tmp;
+                      }
+                  }
+                if (original_asim != NULL)
+                  {
+                    int fore_w, fore_h;
+                    layers[1].im = original_asim;
+                    if( bgPixmap.auto_resize )
+                      {
+                        fore_w = szHint.width;
+                        fore_h = szHint.height;
+                      }
+                    else
+                      {
+                        fore_w = bgPixmap.w;
+                        fore_h = bgPixmap.h;
+                      }
+                    if (fore_w != original_asim->width
+                        || fore_h != original_asim->height)
+                      {
+                        layers[1].im = scale_asimage( display->asv,
+                                                      original_asim,
+                                                      fore_w, fore_h,
+                                                      ASA_ASImage, 100,
+                                                      ASIMAGE_QUALITY_DEFAULT );
+                      }
+
+                    layers[1].clip_width = szHint.width;
+                    layers[1].clip_height = szHint.height;
+
+                    if (rs[Rs_blendtype])
+                      {
+                        layers[1].merge_scanlines = blend_scanlines_name2func(rs[Rs_blendtype]);
+                        if( layers[1].merge_scanlines == NULL )
+                          layers[1].merge_scanlines = alphablend_scanlines;
+                      }
+                  }
+                merged_im = merge_layers( display->asv, layers, layers[1].im?2:1,
+                                          szHint.width, szHint.height,
+                                          ASA_XImage, 0, ASIMAGE_QUALITY_DEFAULT );
+                if (layers[1].im != original_asim)
+                  destroy_asimage( &(layers[1].im) );
+                destroy_asimage( &(layers[0].im) );
+                if (merged_im != NULL)
+                  {
+                    tmp_pmap = asimage2pixmap( display->asv, DefaultRootWindow(dpy), merged_im, gc, True );
+                    destroy_asimage( &merged_im );
+                  }
+                free( layers );
+              }
+          }
+        if (tmp_pmap != None)
+          {
+            success = True;
+            if (pixmap != None)
+              XFreePixmap (dpy, pixmap);
+            pixmap = tmp_pmap;
+          }
+      }
+#else  /* HAVE_AFTERIMAGE */
+      {
       /*
        * Copy display->root pixmap transparency
        */
-      int sx, sy, nx, ny;
-      unsigned int nw, nh;
-      Window cr;
-      XImage *image;
-      GC gc;
-      XGCValues gcvalue;
+        int nx, ny;
+        unsigned int nw, nh;
+        XImage *image;

-      XTranslateCoordinates (dpy, parent[0], display->root,
-                             0, 0, &sx, &sy, &cr);
-      nw = (unsigned int)szHint.width;
-      nh = (unsigned int)szHint.height;
-      nx = ny = 0;
+        nw = (unsigned int)szHint.width;
+        nh = (unsigned int)szHint.height;
+        nx = ny = 0;

-      if (sx < 0)
-        {
-          nw += sx;
-          nx = -sx;
-          sx = 0;
-        }
+        if (sx < 0)
+          {
+            nw += sx;
+            nx = -sx;
+            sx = 0;
+          }

-      if (sy < 0)
-        {
-          nh += sy;
-          ny = -sy;
-          sy = 0;
-        }
+        if (sy < 0)
+          {
+            nh += sy;
+            ny = -sy;
+            sy = 0;
+          }

-      min_it (nw, (unsigned int) (wrootattr.width - sx));
-      min_it (nh, (unsigned int) (wrootattr.height - sy));
+        min_it (nw, (unsigned int) (wrootattr.width - sx));
+        min_it (nh, (unsigned int) (wrootattr.height - sy));

-      XSync (dpy, False);
-      allowedxerror = -1;
-      image = XGetImage (dpy, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap);
+        XSync (dpy, False);
+        allowedxerror = -1;
+        image = XGetImage (dpy, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap);

-      /* XXX: handle BadMatch - usually because we're outside the pixmap */
-      /* XXX: may need a delay here? */
-      allowedxerror = 0;
+        /* XXX: handle BadMatch - usually because we're outside the pixmap */
+        /* XXX: may need a delay here? */
+        allowedxerror = 0;
+        if (image != NULL)
+          {
+            if (pixmap != None)
+              XFreePixmap (dpy, pixmap);
+
+#if TINTING
+            if (ISSET_PIXCOLOR (Color_tint))
+              {
+                int shade = rs[Rs_shade] ? atoi (rs[Rs_shade]) : 100;
+
+                rgba c;
+                pix_colors_focused [Color_tint].get (c);
+                ShadeXImage (this, image, shade, c.r, c.g, c.b);
+              }
+#endif
+
+            pixmap = XCreatePixmap (dpy, vt, szHint.width, szHint.height, image->depth);
+            gc = XCreateGC (dpy, vt, 0UL, &gcvalue);
+            XPutImage (dpy, pixmap, gc, image, 0, 0,
+                       nx, ny, image->width, image->height);
+            XDestroyImage (image);
+            success = True ;
+          }
+      }
+#endif  /* HAVE_AFTERIMAGE */
+      if (gc != NULL)
+        XFreeGC (dpy, gc);

-      if (image == NULL)
+      if (!success)
         {
           if (am_transparent && am_pixmap_trans)
             {
@@ -2589,27 +2763,6 @@ rxvt_term::check_our_parents ()
         }
       else
         {
-          if (pixmap != None)
-            XFreePixmap (dpy, pixmap);
-
-#if TINTING
-          if (ISSET_PIXCOLOR (Color_tint))
-            {
-              int shade = rs[Rs_shade] ? atoi (rs[Rs_shade]) : 100;
-
-              rgba c;
-              pix_colors_focused [Color_tint].get (c);
-
-              ShadeXImage (this, image, shade, c.r, c.g, c.b);
-            }
-#endif
-
-          pixmap = XCreatePixmap (dpy, vt, szHint.width, szHint.height, image->depth);
-          gc = XCreateGC (dpy, vt, 0UL, &gcvalue);
-          XPutImage (dpy, pixmap, gc, image, 0, 0,
-                     nx, ny, image->width, image->height);
-          XFreeGC (dpy, gc);
-          XDestroyImage (image);
           XSetWindowBackgroundPixmap (dpy, parent[0], pixmap);
           XClearWindow (dpy, parent[0]);

@@ -2697,7 +2850,7 @@ rxvt_term::check_our_parents ()
         flush ();
     }

-  return pchanged;
+//  return pchanged;
 }
 #endif

@@ -3948,6 +4101,11 @@ rxvt_term::process_xterm_seq (int op, const char *str, char resp)
               scr_touch (true);
 #endif
             }
+#if TRANSPARENT && defined(HAVE_AFTERIMAGE)
+			    if (option(Opt_transparent))
+		          check_our_parents ();
+#endif
+
         }
         break;

diff --git a/src/init.C b/src/init.C

index 530221ddbdbc621f108d63c3ce2be944d31d1294..

index ..88daf056889d78ab32a083cfc060a32ad4ab84d0 100644

--- a/src/init.C
+++ b/src/init.C
@@ -1037,7 +1037,10 @@ rxvt_term::create_windows (int argc, const char *const *argv)

 #ifdef XPM_BACKGROUND
   if (rs[Rs_backgroundPixmap] != NULL
-      && !option (Opt_transparent))
+#ifndef HAVE_AFTERIMAGE
+      && !OPTION (Opt_transparent)
+#endif
+    )
     {
       const char *p = rs[Rs_backgroundPixmap];

diff --git a/src/main.C b/src/main.C

index b9157ce5004cf8ca9a544c50bbb142cf52a2097f..

index ..f8749dce3c81e1c99f0ca41244d8bff13ae81dfa 100644

--- a/src/main.C
+++ b/src/main.C
@@ -152,6 +152,7 @@ rxvt_term::rxvt_term ()
     :
 #if TRANSPARENT || ENABLE_PERL
     rootwin_ev (this, &rxvt_term::rootwin_cb),
+    check_our_aprents_ev(this, &rxvt_term::check_our_parents_cb),
 #endif
 #ifdef HAVE_SCROLLBARS
     scrollbar_ev (this, &rxvt_term::x_cb),
diff --git a/src/rsinc.h b/src/rsinc.h

index 089a9a07ec8819b180d38beecb840486a3c50e10..

index ..6bf061b8b0080c1e3f2a1f007d83ed38b745cd78 100644

--- a/src/rsinc.h
+++ b/src/rsinc.h
@@ -111,3 +111,7 @@
   def (perl_ext_2)
   def (perl_lib)
 #endif
+#ifdef HAVE_AFTERIMAGE
+  def (blendtype)
+  def (blurradius)
+#endif
diff --git a/src/rxvt.h b/src/rxvt.h

index f61fe409927b56b334b29ba78444af803c6b9b6e..

index ..0587e6fe921ee38dbd6ae72d2171f99bd55eacbc 100644

--- a/src/rxvt.h
+++ b/src/rxvt.h
@@ -75,7 +75,11 @@ typedef char *XPointer;
 #include <termios.h>
 typedef struct termios ttymode_t;

-#ifdef XPM_BACKGROUND
+#ifdef HAVE_AFTERIMAGE
+#  include <afterimage.h>
+#undef min
+#undef max
+#elif defined(XPM_BACKGROUND)
 # ifdef XPM_INC_X11
 #  include <X11/xpm.h>
 # else
@@ -179,6 +183,7 @@ struct grwin_t;
 #ifdef XPM_BACKGROUND
 typedef struct {
   short w, h, x, y;
+  bool auto_resize ;
   Pixmap pixmap;
 } bgPixmap_t;
 #endif
@@ -1018,7 +1023,13 @@ struct rxvt_term : zero_initialized, rxvt_vars, rxvt_screen {
   row_col_t       oldcursor;
 #ifdef XPM_BACKGROUND
   bgPixmap_t      bgPixmap;
+#ifdef HAVE_AFTERIMAGE
+  ASImageManager *asimman;
+  ASImage        *original_asim;
+  struct { unsigned int width, height; } xpmAttr; /* all we need is width/height */
+#else
   XpmAttributes   xpmAttr;    /* originally loaded pixmap and its scaling */
+#endif
 #endif

 #if ENABLE_OVERLAY
@@ -1089,6 +1100,8 @@ struct rxvt_term : zero_initialized, rxvt_vars, rxvt_screen {
 #if TRANSPARENT || ENABLE_PERL
   void rootwin_cb (XEvent &xev);
   xevent_watcher rootwin_ev;
+  void check_our_parents_cb (time_watcher &w);
+  time_watcher check_our_aprents_ev;
 #endif

   void x_cb (XEvent &xev);
diff --git a/src/rxvttoolkit.C b/src/rxvttoolkit.C

index 149bf6db49c2e64ecbc84d5de9926ab377c037eb..

index ..d524ca1661ccb751e67c52d774821d815d00bb88 100644

--- a/src/rxvttoolkit.C
+++ b/src/rxvttoolkit.C
@@ -445,6 +445,11 @@ bool rxvt_display::ref_init ()
   screen = DefaultScreen     (dpy);
   root   = DefaultRootWindow (dpy);

+#ifdef HAVE_AFTERIMAGE
+  ::dpy = dpy; /* init global var from libAfter... */
+  asv = create_asvisual_for_id( dpy, screen, DefaultDepth(dpy,screen), XVisualIDFromVisual(DefaultVisual(dpy,screen)), None, NULL );
+#endif
+
   assert (sizeof (xa_names) / sizeof (char *) == NUM_XA);
   XInternAtoms (dpy, (char **)xa_names, NUM_XA, False, xa);

diff --git a/src/rxvttoolkit.h b/src/rxvttoolkit.h

index 9c0be3f86c6bf312ea87af0f8f80467c14650cc4..

index ..42f8fd297ef51646791b0ef9913eb54b40981a1a 100644

--- a/src/rxvttoolkit.h
+++ b/src/rxvttoolkit.h
@@ -189,6 +189,10 @@ struct rxvt_screen {
   void clear ();
 };

+#ifdef HAVE_AFTERIMAGE
+struct ASVisual;
+#endif
+
 struct rxvt_display : refcounted {
   io_manager_vec<xevent_watcher> xw;

@@ -206,6 +210,9 @@ struct rxvt_display : refcounted {
   Display   *dpy;
   int       screen;
   Window    root;
+#ifdef HAVE_AFTERIMAGE
+  struct ASVisual  *asv;
+#endif
   rxvt_term *selection_owner;
   Atom      xa[NUM_XA];
   bool      is_local;
diff --git a/src/xdefaults.C b/src/xdefaults.C

index be67a0bfbf0a784dfa3cef3b10c6dbb1e551fd9f..

index ..48a9e82aeedebe0c2301c487cb5e8b212e7d581a 100644

--- a/src/xdefaults.C
+++ b/src/xdefaults.C
@@ -260,6 +260,11 @@ optList[] = {
               RSTRG (Rs_perl_ext_1, "perl-ext-common", "string"), //, "colon-separated list of perl extensions to enable"),TODO
               STRG (Rs_perl_ext_2, "perl-ext", "pe", "string", "colon-separated list of perl extensions to enable for this instance"),
 #endif
+
+#ifdef HAVE_AFTERIMAGE
+              STRG (Rs_blendtype, "blendType", "blt", "string", "background image blending type - alpha, tint, etc..."),
+              STRG (Rs_blurradius, "blurRadius", "blr", "number", "Gaussian Blur radius to apply to the root background"),
+#endif
 #ifndef NO_RESOURCES
               INFO ("xrm", "string", "X resource"),
 #endif
diff --git a/src/xpm.C b/src/xpm.C

index 36a6b499d57ec9c8dddd848fc49b7845a5b4b118..

index ..03f980aee47d804967a34aa9914c9c532f09bfb3 100644

--- a/src/xpm.C
+++ b/src/xpm.C
@@ -85,7 +85,20 @@ rxvt_term::scale_pixmap (const char *geom)
       strncpy (str, geom, n);
       str[n] = '\0';

-      flags = XParseGeometry (str, &x, &y, &w, &h);
+      if (strcmp(str, "auto") == 0)
+        {
+          if (!bgpixmap->auto_resize)
+            changed++;
+          bgpixmap->auto_resize = True ;
+          w = szHint.width ;
+          h = szHint.height ;
+          flags = WidthValue|HeightValue ;
+        }
+      else
+        {
+          bgpixmap->auto_resize = False ;
+          flags = XParseGeometry (str, &x, &y, &w, &h);
+        }

       if (!flags)
         {
@@ -171,7 +184,10 @@ rxvt_term::resize_pixmap ()
   GC gc;

   if (pixmap != None)
-    XFreePixmap (dpy, pixmap);
+    {
+      XFreePixmap (dpy, pixmap);
+      pixmap = None ;
+    }

   if (bgPixmap.pixmap == None)
     { /* So be it: I'm not using pixmaps */
@@ -195,6 +211,11 @@ rxvt_term::resize_pixmap ()
       unsigned int xpmh = xpmAttr.height,
                    xpmw = xpmAttr.width;

+      if (bgPixmap.auto_resize)
+        {
+          w = szHint.width ;
+          h = szHint.height ;
+        }
       /*
        * don't zoom pixmap too much nor expand really small pixmaps
        */
@@ -215,6 +236,20 @@ rxvt_term::resize_pixmap ()
           XCopyArea (dpy, bgPixmap.pixmap, pixmap, gc, 0, 0,        x,        y, xpmw - x, xpmh - y);
         }
       else
+#ifdef HAVE_AFTERIMAGE
+#ifdef TRANSPARENT
+      if (!option(Opt_transparent) || !am_transparent)
+      /* will do that in check_our_parents otherwise */
+#endif
+        {
+          ASImage *scaled_im = scale_asimage( display->asv, original_asim, w, h, ASA_XImage, 0, ASIMAGE_QUALITY_DEFAULT );
+          if (scaled_im)
+            {
+              pixmap = asimage2pixmap( display->asv, display->root, scaled_im, gc, True );
+              destroy_asimage( &scaled_im );
+            }
+        }
+#else   /* HAVE_AFTERIMAGE */
         {
           float incr, p;
           Pixmap tmp;
@@ -259,6 +294,7 @@ rxvt_term::resize_pixmap ()

           XFreePixmap (dpy, tmp);
         }
+#endif /* HAVE_AFTERIMAGE */
     }

   XSetWindowBackgroundPixmap (dpy, vt, pixmap);
@@ -369,6 +405,24 @@ rxvt_term::set_bgPixmap (const char *file)
        */
       /*      XGetWindowAttributes (dpy, vt, &attr); */

+#ifdef HAVE_AFTERIMAGE
+      if (asimman == NULL)
+        asimman = create_generic_imageman(rs[Rs_path]);
+      if ((f = strchr (file, ';')) == NULL)
+        original_asim = get_asimage( asimman, file, 0xFFFFFFFF, 100 );
+      else
+        {
+          f = strndup( file, f - file );
+          original_asim = get_asimage( asimman, f, 0xFFFFFFFF, 100 );
+          free( f );
+        }
+      if (original_asim)
+        {
+          bgPixmap.pixmap = asimage2pixmap( display->asv, display->root, original_asim, NULL, True );
+          xpmAttr.width = original_asim->width ;
+          xpmAttr.height = original_asim->height ;
+        }
+#else /* HAVE_AFTERIMAGE */
       xpmAttr.closeness = 30000;
       xpmAttr.colormap = cmap;
       xpmAttr.visual = visual;
@@ -391,8 +445,8 @@ rxvt_term::set_bgPixmap (const char *file)

           rxvt_warn ("couldn't load XPM file \"%.*s\", ignoring.\n", (p - file), file);
         }
-
       free (f);
+#endif /* HAVE_AFTERIMAGE */
     }

   resize_pixmap ();

-----END OF PAGE-----

-- Response ended

-- Page fetched on Sun Jun 2 13:09:16 2024