repo: rxvt-unicode-sixel
action: commit
revision: 
path_from: 
revision_from: 31163df6c98bcb970ce2388318445f1e244c3011:
path_to: 
revision_to: 
git.thebackupbox.net
rxvt-unicode-sixel
git clone git://git.thebackupbox.net/rxvt-unicode-sixel
commit 31163df6c98bcb970ce2388318445f1e244c3011
Author: Marc Lehmann 
Date:   Thu Jun 7 17:04:33 2012 +0000

    µcorrectness

diff --git a/src/perl/background b/src/perl/background
index 1bb5383d3d5b207e6fe4e9a3a2bfbf3f8934f003..
index ..617f628700b7f8f0921179dd72e5ef66a3dc7131 100644
--- a/src/perl/background
+++ b/src/perl/background
@@ -196,6 +196,12 @@ way that pixels outside the image area are painted when the image is used.
 Tiles the whole plane with the image and returns this new image - or in
 other words, it returns a copy of the image in plane tiling mode.

+Example: load an image and tile it over the background, without
+resizing. The C call is superfluous because C already defaults
+to tiling mode.
+
+   tile load "mybg.png"
+
 =item mirror $img

 Similar to tile, but reflects the image each time it uses a new copy, so
@@ -203,6 +209,11 @@ that top edges always touch top edges, right edges always touch right
 edges and so on (with normal tiling, left edges always touch right edges
 and top always touch bottom edges).

+Exmaple: load an image and mirror it over the background, avoiding sharp
+edges at the image borders at the expense of mirroring the image itself
+
+   mirror load "mybg.png"
+
 =item pad $img

 Takes an image and modifies it so that all pixels outside the image area
@@ -210,6 +221,12 @@ become transparent. This mode is most useful when you want to place an
 image over another image or the background colour while leaving all
 background pixels outside the image unchanged.

+Example: load an image and display it in the upper left corner. The rets
+of the space is left "empty" (transparent or wahtever your compisotr does
+in alpha mode, else background colour).
+
+   pad load "mybg.png"
+
 =item extend $img

 Extends the image over the whole plane, using the closest pixel in the
@@ -217,6 +234,10 @@ area outside the image. This mode is mostly useful when you more complex
 filtering operations and want the pixels outside the image to have the
 same values as the pixels near the edge.

+Example: just for curiosity, how does this pixel extension stuff work?
+
+   extend move 50, 50, load "mybg.png"
+
 =cut

    sub pad($) {
@@ -423,6 +444,9 @@ sub recalculate {
    warn $@ if $@;#d#
    die if !UNIVERSAL::isa $img, "urxvt::img";

+   $state->{size_sensitive} = 1
+      if $img->repeat_mode != urxvt::RepeatNormal;
+
    # if the expression is sensitive to external events, prepare reevaluation then

    my $repeat;
@@ -467,10 +491,7 @@ sub recalculate {
       delete $self->{expr};
    }

-   # prepare and set background pixmap
-
-   $img = $img->sub_rect (0, 0, $w, $h)
-      if $img->w != $w || $img->h != $h;
+   # set background pixmap

    $self->set_background ($img, $self->{border});
    $self->scr_recolour (0);
diff --git a/src/rxvtperl.xs b/src/rxvtperl.xs
index f9090e61f6e90c8a2797b98bc19ef2a145196c8c..
index ..6b45d1b6b292cb6d73eb1950a393b11b8c39fbce 100644
--- a/src/rxvtperl.xs
+++ b/src/rxvtperl.xs
@@ -2098,16 +2098,30 @@ rxvt_term::set_background (rxvt_img *img, bool border = false)

         if (img) // TODO: cannot be false
           {
-            img = img->reify ();
-            rxvt_img *img2 = img->convert_to (XRenderFindVisualFormat (THIS->dpy, THIS->visual), THIS->pix_colors [Color_bg]);
-            delete img;
-            THIS->bg_pixmap = img2->steal ();
+            img = img->clone (); // own the img
+
+            if (img->repeat != RepeatNormal) // X11 only supports RepeatNormal as bg pixmap
+              {
+                rxvt_img *img2 = img->sub_rect (0, 0,
+                                                border ? THIS->vt_width  : THIS->szHint.width,
+                                                border ? THIS->vt_height : THIS->szHint.height);
+                delete img;
+                img = img2;
+              }
+
+            {
+              rxvt_img *img2 = img->convert_to (XRenderFindVisualFormat (THIS->dpy, THIS->visual), THIS->pix_colors [Color_bg]);
+              delete img;
+              img = img2;
+            }
+
+            THIS->bg_pixmap = img->steal ();
             THIS->bg_flags |= rxvt_term::BG_NEEDS_REFRESH | rxvt_term::BG_INHIBIT_RENDER;

             if (!border)
               THIS->bg_flags |= rxvt_term::BG_IS_TRANSPARENT;

-            THIS->bg_valid_since = ev::now (); // TODO: extra bloat
+            delete img;
           }

 #endif
@@ -2191,8 +2205,13 @@ rxvt_img::DESTROY ()
 void
 rxvt_img::unshare ()

-void
-rxvt_img::repeat_mode (render_repeat_mode repeat = RepeatNormal)
+int
+rxvt_img::repeat_mode (render_repeat_mode repeat = 0)
+	CODE:
+        if (items >= 2)
+          THIS->repeat_mode (repeat);
+        if (GIMME_V != G_VOID)
+          XPUSHs (sv_2mortal (newSViv (THIS->repeat)));

 void
 rxvt_img::move (int dx, int dy)

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