-- 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: ebb8ac41b41c67adb923fa96ac0414cf764e6504:
path_to:
revision_to:

git.thebackupbox.net

rxvt-unicode-sixel

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

commit ebb8ac41b41c67adb923fa96ac0414cf764e6504
Author: Sasha Vasko <sashavasko@gmail.com>
Date:   Thu Nov 15 18:40:11 2007 +0000

    added new geometry op of :root to implement automove-background functionality internally , since absolute pixmap placement no longer supported

diff --git a/Changes b/Changes

index 8ff035a57933f4292370f38f34efc85a0ea99aaa..

index ..2427c04db7dc1e03dd273dcfb87f6d1108dd7b66 100644

--- a/Changes
+++ b/Changes
@@ -19,10 +19,11 @@ DUMB: support tex fonts

 TODO: align default value of cutchars with rxvt.1.pod and add it as a fallback in perl 'selection'
       http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=377194
-TODO: automove-background
         - expect major compatibility issues and please test and report.
       	- converted from the veritable io manager event loop to
           the high performance libev (http://software.schmorp.de/pkg/libev).
+    - automove-background functionality re-implemented internaly using :root op in pixmap
+	  geometry string. For example: rxvt -pixmap "image.jpg;:root"
 	- fix a serious bug while setting the XIM destroy callback
           on (typical) 64 bit systems.
 	- fix memory leak in pixmap code.
diff --git a/doc/rxvt.1.pod b/doc/rxvt.1.pod

index 78cabd14702f8222838bec7af3425584d4e3933d..

index ..8986325d31d9dc6898e50d7c59d46b3080557237 100644

--- a/doc/rxvt.1.pod
+++ b/doc/rxvt.1.pod
@@ -186,7 +186,7 @@ Window background colour; resource B<background>.

 Window foreground colour; resource B<foreground>.

-=item B<-pixmap> I<file[;geom]>
+=item B<-pixmap> I<file[;geom[:op1][:op2][...]]>

 Compile I<afterimage>: Specify image file for the background and also
 optionally specify its scaling with a geometry string. Note you may need to
@@ -695,7 +695,7 @@ Use the specified colour for the scrollbar's trough area [default
 The colour of the border around the text area and between the scrollbar
 and the text.

-=item B<backgroundPixmap:> I<file[;geom]>
+=item B<backgroundPixmap:> I<file[;geom[:op1][:op2][...]]>

 Use the specified image file for the background and also optionally
 specify its scaling with a geometry string B<WxH+X+Y>,
@@ -705,8 +705,17 @@ 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.
+Additional operations can be specified after colon B<:op1:op2...>.
+Supported operations are:
+  B<"tile"> - force background image to be tiled and not scaled. Equivalent to 0x0,
+  B<"propscale"> - will scale image keeping proportions,
+  B<"auto"> - will scale image to match window size. Equivalent to 100x100;
+  B<"hscale"> - will scale image horizontally to the window size;
+  B<"vscale"> - will scale image vertically to the window size;
+  B<"scale"> - will scale image to match window size;
+  B<"root"> - will tile image as if it was a root window background, auto-adjusting
+    whenever terminal window moves.
+
 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.
diff --git a/doc/rxvt.7.pod b/doc/rxvt.7.pod

index 5ce583cc80984092bf828c739601610cef3e47e6..

index ..b640f5b484813942821ca4ae5220d9394e99ddd0 100644

--- a/doc/rxvt.7.pod
+++ b/doc/rxvt.7.pod
@@ -231,9 +231,9 @@ to use effects other than tinting and shading: Just shade/tint/whatever
 your picture with gimp or any other tool:

    convert wallpaper.jpg -blur 20x20 -modulate 30 background.jpg
-   @@URXVT_NAME@@ -pixmap background.jpg -pe automove-background
+   @@URXVT_NAME@@ -pixmap "background.jpg;:root"

-That works. If you think it doesn't, you lack AfterImage and Perl support, or you
+That works. If you think it doesn't, you lack AfterImage support, or you
 are unable to read.

 3. Use an ARGB visual:
diff --git a/src/background.C b/src/background.C

index 1fb6ccd9f2285757c3c983b77364e5a1993c4bf6..

index ..df1fb47d6c99e96ac0241d899c5710b492cb228f 100644

--- a/src/background.C
+++ b/src/background.C
@@ -115,6 +115,11 @@ bgPixmap_t::~bgPixmap_t()
 bool
 bgPixmap_t::window_size_sensitive ()
 {
+# ifdef ENABLE_TRANSPARENCY
+  if (flags & isTransparent)
+    return true;
+# endif
+
 # ifdef BG_IMAGE_FROM_FILE
 #  ifdef HAVE_AFTERIMAGE
   if (original_asim != NULL)
@@ -125,12 +130,30 @@ bgPixmap_t::window_size_sensitive ()
         return true;
     }
 # endif
+
+  return false;
+}
+
+bool
+bgPixmap_t::window_position_sensitive ()
+{
 # ifdef ENABLE_TRANSPARENCY
   if (flags & isTransparent)
     return true;
 # endif
+
+# ifdef BG_IMAGE_FROM_FILE
+#  ifdef HAVE_AFTERIMAGE
+  if (original_asim != NULL)
+#  endif
+    {
+      if (h_align == rootAlign || v_align == rootAlign)
+        return true;
+    }
+# endif
+
   return false;
-}
+};

 bool bgPixmap_t::need_client_side_rendering ()
 {
@@ -174,10 +197,13 @@ check_set_align_value (int geom_flags, int flag, int &align, int new_value)
 {
   if (geom_flags & flag)
     {
-      if (new_value < -100)
-        new_value = -100;
-      else if (new_value > 200)
-        new_value = 200;
+      if (new_value != bgPixmap_t::rootAlign)
+        {
+          if (new_value < -100)
+            new_value = -100;
+          else if (new_value > 200)
+            new_value = 200;
+        }
       if (new_value != align)
         {
           align = new_value;
@@ -341,14 +367,14 @@ bgPixmap_t::set_geometry (const char *geom)
 #  define CHECK_GEOM_OPS(op_str)  (strncasecmp (ops, (op_str), sizeof(op_str)-1) == 0)
               if (CHECK_GEOM_OPS("tile"))
                 {
-                  w = h = 0;
+                  w = h = noScale;
                   geom_flags |= WidthValue|HeightValue;
                 }
               else if (CHECK_GEOM_OPS("propscale"))
                 {
                   if (w == 0 && h == 0)
                     {
-                      w = 100;
+                      w = windowScale;
                       geom_flags |= WidthValue;
                     }
                   new_flags |= propScale;
@@ -356,29 +382,35 @@ bgPixmap_t::set_geometry (const char *geom)
               else if (CHECK_GEOM_OPS("hscale"))
                 {
                   if (w == 0)
-                    w = 100;
-                  h = 0;
+                    w = windowScale;
+                  h = noScale;
                   geom_flags |= WidthValue|HeightValue;
                 }
               else if (CHECK_GEOM_OPS("vscale"))
                 {
                   if (h == 0)
-                    h = 100;
-                  w = 0;
+                    h = windowScale;
+                  w = noScale;
                   geom_flags |= WidthValue|HeightValue;
                 }
               else if (CHECK_GEOM_OPS("scale"))
                 {
                   if (h == 0)
-                    h = 100;
+                    h = windowScale;
                   if (w == 0)
-                    w = 100;
+                    w = windowScale;
                   geom_flags |= WidthValue|HeightValue;
                 }
               else if (CHECK_GEOM_OPS("auto"))
                 {
-                  w = h = 100;
-                  x = y = 50;
+                  w = h = windowScale;
+                  x = y = centerAlign;
+                  geom_flags |= WidthValue|HeightValue|XValue|YValue;
+                }
+              else if (CHECK_GEOM_OPS("root"))
+                {
+                  w = h = noScale;
+                  x = y = rootAlign;
                   geom_flags |= WidthValue|HeightValue|XValue|YValue;
                 }
 #  undef CHECK_GEOM_OPS
@@ -427,8 +459,16 @@ bgPixmap_t::render_asim (ASImage *background, ARGB32 background_tint)

   if (original_asim)
     {
-      x = make_align_position (h_align, target_width, w > 0 ? w : (int)original_asim->width);
-      y = make_align_position (v_align, target_height, h > 0 ? h : (int)original_asim->height);
+      if (h_align == rootAlign || v_align == rootAlign)
+        {
+          target->get_window_origin(x, y);
+          x = -x;
+          y = -y;
+        }
+      if (h_align != rootAlign)
+        x = make_align_position (h_align, target_width, w > 0 ? w : (int)original_asim->width);
+      if (v_align != rootAlign)
+        y = make_align_position (v_align, target_height, h > 0 ? h : (int)original_asim->height);
     }

   if (original_asim == NULL
@@ -467,18 +507,20 @@ bgPixmap_t::render_asim (ASImage *background, ARGB32 background_tint)
                                   100, ASIMAGE_QUALITY_DEFAULT);
         }
       if (background == NULL)
-        {/* if tiling - pixmap has to be sized exactly as the image */
+        {/* if tiling - pixmap has to be sized exactly as the image,
+            but there is no need to make it bigger then the window! */
           if (h_scale == 0)
-            new_pmap_width = result->width;
+            new_pmap_width = min (result->width, target_width);
           if (v_scale == 0)
-            new_pmap_height = result->height;
+            new_pmap_height = min (result->height, target_height);
           /* we also need to tile our image in one or both directions */
           if (h_scale == 0 || v_scale == 0)
             {
               ASImage *tmp = tile_asimage (target->asv, result,
                                             (h_scale > 0) ? 0 : (int)result->width - x,
                                             (v_scale > 0) ? 0 : (int)result->height - y,
-                                            result->width, result->height,
+                                            new_pmap_width,
+                                            new_pmap_height,
                                             TINT_LEAVE_SAME, ASA_XImage,
                                             100, ASIMAGE_QUALITY_DEFAULT);
               if (tmp)
diff --git a/src/background.h b/src/background.h

index 1aa741d9a7c92731a0ccd86dd20575296e3fae4d..

index ..c348d6eeb6ab053ba00e2ba2c46bb79d098ec9a3 100644

--- a/src/background.h
+++ b/src/background.h
@@ -55,7 +55,10 @@ struct  bgPixmap_t {
   bool render_asim (ASImage *background, ARGB32 background_tint);
 #  endif

-  enum { defaultScale = 100, defaultAlign = 50 };
+  enum {
+    noScale = 0, windowScale = 100, defaultScale = windowScale,
+    centerAlign = 50, defaultAlign = centerAlign,
+	rootAlign = -10000 };

   unsigned int h_scale, v_scale;/* percents of the window size */
   int h_align, v_align;         /* percents of the window size:
@@ -98,9 +101,7 @@ struct  bgPixmap_t {
   unsigned int pmap_depth;

   bool window_size_sensitive ();
-  bool window_position_sensitive () {
-    return (flags & isTransparent);
-  };
+  bool window_position_sensitive ();

   bool is_parentOrigin () {
     return !(flags & isVtOrigin);
diff --git a/src/main.C b/src/main.C

index c9cc6510217114b0fcb681bbfd1584f9d014c0a4..

index ..f7474c4035f7b2a07f630be5076a7a9436db5dfc 100644

--- a/src/main.C
+++ b/src/main.C
@@ -1740,6 +1740,14 @@ rxvt_term::get_pixmap_property (int prop_id)
 }

 #ifdef HAVE_BG_PIXMAP
+# if TRACE_PIXMAPS
+#  undef update_background
+int rxvt_term::trace_update_background (const char* file, int line)
+{
+  fprintf (stderr, "%s:%d:update_background()\n", file, line);
+  update_background ();
+}
+# endif
 int
 rxvt_term::update_background ()
 {
diff --git a/src/rxvt.h b/src/rxvt.h

index 0187eb8e92ad129626246114cf41afc938f244a8..

index ..a0c2349300c9a0f6a8d4dd66ac22de33651a7219 100644

--- a/src/rxvt.h
+++ b/src/rxvt.h
@@ -1050,6 +1050,10 @@ struct rxvt_term : zero_initialized, rxvt_vars, rxvt_screen {
 #endif
 #ifdef HAVE_BG_PIXMAP
   int update_background ();
+#if TRACE_PIXMAPS
+  int trace_update_background (const char* file, int line);
+# define update_background() trace_update_background (__FILE__, __LINE__)
+#endif
   void update_background_cb (ev::timer &w, int revents);
   ev::timer update_background_ev;
 #endif

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

-- Response ended

-- Page fetched on Sun Jun 2 09:45:45 2024