repo: rxvt-unicode-sixel
action: commit
revision: 
path_from: 
revision_from: 8b8bf380bbb1570dfbbbee31823e4745b54d2c56:
path_to: 
revision_to: 
git.thebackupbox.net
rxvt-unicode-sixel
git clone git://git.thebackupbox.net/rxvt-unicode-sixel
commit 8b8bf380bbb1570dfbbbee31823e4745b54d2c56
Author: Emanuele Giaquinta 
Date:   Thu Aug 11 08:37:17 2011 +0000

    Overhaul of the bg image operations.

    Remove old operations in favour of simple operations to perform tiling,
    proportional scaling and root window-like positioning. Add styles, in
    terms of the low level scale, position and operations settings, for the
    most common setups (old operations are still parsed for backward
    compatibility).

diff --git a/doc/rxvt.1.pod b/doc/rxvt.1.pod
index 311d53db4577db418aa63aecc30ab930a178b5d5..
index ..b01ab78d57bdf1e72783abf1adbe47a5a5ddb28a 100644
--- a/doc/rxvt.1.pod
+++ b/doc/rxvt.1.pod
@@ -756,12 +756,31 @@ The maximum permitted scale is 1000.
 Additional operations can be specified after colon B<:op1:op2...>.
 Supported operations are:

-  tile        will tile image
-  propscale   will scale image keeping proportions
-  scale       will scale image to match window size
-  center      will center image with no scaling
-  root        will tile image as if it was a root window background, auto-adjusting
-              whenever terminal window moves
+  op=tile     enables tiling
+  op=pscale   enables proportional scaling
+  op=root     use the position of the terminal window relative to the root
+              window as the image offset, simulating a root window background
+
+Alternatively, a predefined set of templates can be used to achieve
+the most common setups:
+
+  style=tiled              the image is tiled with no scaling
+  style=aspect-stretched   the image is scaled to fill the whole window maintaining
+                           the aspect ratio and centered 
+  style=stretched          the image is scaled to fill the whole window
+  style=centered           the image is centered with no scaling
+  style=root-tiled         the image is tiled with no scaling and using 'op=root' positioning
+
+If multiple templates are specified the last one wins. Note that a
+template overrides all the scale, position and operations settings.
+Indeed, the templates can be specified in terms of low level settings
+as follows:
+
+  style=tiled              0x0+0+0:op=tile
+  style=aspect-stretched   +50+50:op=pscale
+  style=stretched          100x100
+  style=centered           0x0+50+50
+  style=root-tiled         0x0:op=tile:op=root

 If used in conjunction with B<-tr> option, the specified pixmap will be
 blended over the transparent background using alpha-blending. If I
diff --git a/src/background.C b/src/background.C
index f41428c2d742d1ce0a41aff99e8e087a5480610d..
index ..b12641597184d1debba90f446c24b85d7fa0c2f7 100644
--- a/src/background.C
+++ b/src/background.C
@@ -48,13 +48,6 @@
  *            the image in the window.
  *
  * Pixmap Operations : (should be prepended by a colon)
- * tile       Tile image. Scaling/position modifiers above will affect
- *            the tile size and origin.
- * propscale  When scaling, scale proportionally. That is, maintain the
- *            proper aspect ratio for the image. Any portion of the
- *            background not covered by the image is filled with the
- *            current background color.
- * scale      Scale both up and down
  */

 #ifdef HAVE_BG_PIXMAP
@@ -257,7 +250,47 @@ rxvt_term::bg_set_geometry (const char *geom, bool update)

       for (int i = 0; arr[i]; i++) 
         {
-          if (!strcasecmp (arr[i], "tile"))
+          if (!strcasecmp (arr[i], "style=tiled"))
+            {
+              new_flags = BG_TILE;
+              w = h = noScale;
+              x = y = 0;
+              geom_flags = WidthValue|HeightValue|XValue|YValue;
+            }
+          else if (!strcasecmp (arr[i], "style=aspect-stretched"))
+            {
+              new_flags = BG_PROP_SCALE;
+              x = y = centerAlign;
+              geom_flags = XValue|YValue;
+            }
+          else if (!strcasecmp (arr[i], "style=stretched"))
+            {
+              new_flags = 0;
+              w = h = windowScale;
+              geom_flags = WidthValue|HeightValue;
+            }
+          else if (!strcasecmp (arr[i], "style=centered"))
+            {
+              new_flags = 0;
+              w = h = noScale;
+              x = y = centerAlign;
+              geom_flags = WidthValue|HeightValue|XValue|YValue;
+            }
+          else if (!strcasecmp (arr[i], "style=root-tiled"))
+            {
+              new_flags = BG_TILE|BG_ROOT_ALIGN;
+              w = h = noScale;
+              geom_flags = WidthValue|HeightValue;
+            }
+          else if (!strcasecmp (arr[i], "op=tile"))
+            new_flags |= BG_TILE;
+          else if (!strcasecmp (arr[i], "op=pscale"))
+            new_flags |= BG_PROP_SCALE;
+          else if (!strcasecmp (arr[i], "op=root"))
+            new_flags |= BG_ROOT_ALIGN;
+
+          // deprecated
+          else if (!strcasecmp (arr[i], "tile"))
             {
               new_flags |= BG_TILE;
               w = h = noScale;
@@ -274,12 +307,6 @@ rxvt_term::bg_set_geometry (const char *geom, bool update)

               geom_flags |= WidthValue|HeightValue;
             }
-          else if (!strcasecmp (arr[i], "center"))
-            {
-              w = h = noScale;
-              x = y = centerAlign;
-              geom_flags |= WidthValue|HeightValue|XValue|YValue;
-            }
           else if (!strcasecmp (arr[i], "root"))
             {
               new_flags |= BG_TILE|BG_ROOT_ALIGN;

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