I have written a patch that adds two wallpaper position modes to the
compiz-extra wallpaper plugin.
1. If an image is, for example, very tall, it should be scaled
proportionally like dante-scale-proportionally, but not like
dante-scale (fitting all the screen but not saving proportions).
The new mode is called "Scale Proportionally".
2. If an image should be scaled to cover the whole screen, it must be
cropped. Some images should not be cropped both at the top and bottom.
A new mode called "Scale and Crop Bottom" is proposed
(shaiyald-scale-and-crop-bottom). On the picture, the head is not
cropped, but the legs are.

Since I am a Russian I have made a patch for ru.po file.
diff -Naur 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 
17:09:17.000000000 +0300
+++ compiz-plugins-extra-0.8.6/metadata/wallpaper.xml.in        2011-03-01 
13:31:55.000000000 +0200
@@ -24,7 +24,7 @@
                                        <_long>Image position.</_long>
                                        <type>int</type>
                                        <min>0</min>
-                                       <max>4</max>
+                                       <max>6</max>
                                        <desc>
                                                <value>0</value>
                                                <_name>Scale and Crop</_name>
@@ -45,6 +45,14 @@
                                                <value>4</value>
                                                <_name>Center Tiled</_name>
                                        </desc>
+                                       <desc>
+                                               <value>5</value>
+                                               <_name>Scale and Crop 
Bottom</_name>
+                                       </desc>
+                                       <desc>
+                                               <value>6</value>
+                                               <_name>Scaled 
Proportionally</_name>
+                                       </desc>
                                </option>
                                <option name="bg_fill_type" type="list">
                                        <_short>Fill type</_short>
diff -Naur 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 
17:09:18.000000000 +0300
+++ compiz-plugins-extra-0.8.6/src/wallpaper/wallpaper.c        2011-03-01 
13:37:54.000000000 +0200
@@ -733,6 +733,41 @@
                tmpRegion.extents.x2 = MIN (s->width, x + back->width);
                tmpRegion.extents.y2 = MIN (s->height, y + back->height);
            }
+           else if (back->imagePos == BgImagePosScaleAndCropBottom)
+           {
+               s1 = (float) s->width / back->width;
+               s2 = (float) s->height / back->height;
+
+               s1 = MAX (s1, s2);
+
+               tmpMatrix.xx /= s1;
+               tmpMatrix.yy /= s1;
+
+               x = (s->width - ((int)back->width * s1)) / 2.0;
+               tmpMatrix.x0 -= x * tmpMatrix.xx;
+           }
+           else if (back->imagePos == BgImagePosScaledProportionally)
+           {
+               s1 = (float) s->width / back->width;
+               s2 = (float) s->height / back->height;
+
+               s1 = MIN (s1, s2);
+
+               tmpMatrix.xx /= s1;
+               tmpMatrix.yy /= s1;
+
+               x = (s->width - ((int)back->width * s1)) / 2.0;
+               tmpMatrix.x0 -= x * tmpMatrix.xx;
+               y = (s->height - ((int)back->height * s1)) / 2.0;
+               tmpMatrix.y0 -= y * tmpMatrix.yy;
+               
+               reg = &tmpRegion;
+               
+               tmpRegion.extents.x1 = MAX (0, x);
+               tmpRegion.extents.y1 = MAX (0, y);
+               tmpRegion.extents.x2 = MIN (s->width, x + back->width * s1);
+               tmpRegion.extents.y2 = MIN (s->height, y + back->height * s1);
+            }
 
            if (back->imagePos == BgImagePosTiled ||
                back->imagePos == BgImagePosCenterTiled)
diff -Naur compiz-plugins-extra-0.8.6.orig/po/ru.po 
compiz-plugins-extra-0.8.6/po/ru.po
--- compiz-plugins-extra-0.8.6.orig/po/ru.po    2010-03-29 17:09:18.000000000 
+0300
+++ compiz-plugins-extra-0.8.6/po/ru.po 2011-03-01 13:31:55.000000000 +0200
@@ -5949,6 +5949,12 @@
 msgid "Scaled"
 msgstr "Растянуть"
 
+msgid "Scaled Proportionally"
+msgstr "Растянуть, сохраняя пропорции"
+
+msgid "Scale and Crop Bottom"
+msgstr "Масштабировать, срезав снизу"
+
 msgid "Second gradient color."
 msgstr "Второй цвет градиента"
 

<<attachment: shaiyald-scale-and-crop-bottom.JPG>>

<<attachment: dante-scale.JPG>>

<<attachment: dante-scale-proportionally.JPG>>

_______________________________________________
dev mailing list
[email protected]
http://lists.compiz.org/mailman/listinfo/dev

Reply via email to