nixpkgs-suyu/pkgs/applications/window-managers/compiz/wallpaper-maxpect.patch
Eelco Dolstra 23914238d1 * compiz-plugins-extra: Wrote a patch to add "centered maxpect"
scaling mode for background images (as in KDE), i.e., scale the
  image to the maximum size while preserving its aspect ratio.

svn path=/nixpkgs/trunk/; revision=24394
2010-10-20 23:16:51 +00:00

58 lines
2.2 KiB
Diff

diff -x '*~' -ru compiz-plugins-extra-0.8.6-orig/metadata/wallpaper.xml.in compiz-plugins-extra-0.8.6/metadata/wallpaper.xml.in
--- compiz-plugins-extra-0.8.6-orig/metadata/wallpaper.xml.in 2010-03-29 16:09:17.000000000 +0200
+++ compiz-plugins-extra-0.8.6/metadata/wallpaper.xml.in 2010-10-21 00:23:18.000000000 +0200
@@ -24,7 +24,7 @@
<_long>Image position.</_long>
<type>int</type>
<min>0</min>
- <max>4</max>
+ <max>5</max>
<desc>
<value>0</value>
<_name>Scale and Crop</_name>
@@ -45,6 +45,10 @@
<value>4</value>
<_name>Center Tiled</_name>
</desc>
+ <desc>
+ <value>5</value>
+ <_name>Centered Maxpect</_name>
+ </desc>
</option>
<option name="bg_fill_type" type="list">
<_short>Fill type</_short>
diff -x '*~' -ru compiz-plugins-extra-0.8.6-orig/src/wallpaper/wallpaper.c compiz-plugins-extra-0.8.6/src/wallpaper/wallpaper.c
--- compiz-plugins-extra-0.8.6-orig/src/wallpaper/wallpaper.c 2010-03-29 16:09:18.000000000 +0200
+++ compiz-plugins-extra-0.8.6/src/wallpaper/wallpaper.c 2010-10-21 01:09:10.000000000 +0200
@@ -697,12 +697,12 @@
tmpMatrix = back->imgTex.matrix;
- if (back->imagePos == BgImagePosScaleAndCrop)
+ if ((back->imagePos == BgImagePosScaleAndCrop) || (back->imagePos == BgImagePosCenteredMaxpect))
{
s1 = (float) s->width / back->width;
s2 = (float) s->height / back->height;
- s1 = MAX (s1, s2);
+ s1 = back->imagePos == BgImagePosScaleAndCrop ? MAX (s1, s2) : MIN (s1, s2);
tmpMatrix.xx /= s1;
tmpMatrix.yy /= s1;
@@ -711,6 +711,16 @@
tmpMatrix.x0 -= x * tmpMatrix.xx;
y = (s->height - ((int)back->height * s1)) / 2.0;
tmpMatrix.y0 -= y * tmpMatrix.yy;
+
+ if (back->imagePos == BgImagePosCenteredMaxpect)
+ {
+ reg = &tmpRegion;
+
+ tmpRegion.extents.x1 = MAX (0, x);
+ tmpRegion.extents.y1 = MAX (0, y);
+ tmpRegion.extents.x2 = MIN (s->width, x + ((int) back->width * s1));
+ tmpRegion.extents.y2 = MIN (s->height, y + ((int) back->height * s1));
+ }
}
else if (back->imagePos == BgImagePosScaled)
{