3
0
Fork 0
forked from mirrors/nixpkgs

* 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
This commit is contained in:
Eelco Dolstra 2010-10-20 23:16:51 +00:00
parent edc04aeef5
commit 23914238d1
2 changed files with 64 additions and 0 deletions

View file

@ -11,6 +11,12 @@ stdenv.mkDerivation rec {
sha256 = "1qbxfi332bbadm0ah48frnrl9dkczl111s5a91a0cqz5v7nbw4g1";
};
patches =
[ # Support scaling wallpapers to the maximum size while still
# respecting the aspect ratio.
./wallpaper-maxpect.patch
];
NIX_CFLAGS_COMPILE = "-I${compiz_plugins_main}/include/compiz";
buildInputs =

View file

@ -0,0 +1,58 @@
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)
{