[Xfce4-commits] <ristretto:master> Improve rendering of wallpaper

Stephan Arts noreply at xfce.org
Wed Nov 23 06:54:07 CET 2011


Updating branch refs/heads/master
         to d6b305c302f20a98771a8390c3d6240bc265d553 (commit)
       from cdc0f4e3e290aebac942ca6cd5b34f24ac794c19 (commit)

commit d6b305c302f20a98771a8390c3d6240bc265d553
Author: Stephan Arts <stephan at xfce.org>
Date:   Wed Nov 23 06:43:32 2011 +0100

    Improve rendering of wallpaper

 src/monitor_chooser.c        |    8 ++++----
 src/xfce_wallpaper_manager.c |   27 +++++++++++++++++++++++----
 2 files changed, 27 insertions(+), 8 deletions(-)

diff --git a/src/monitor_chooser.c b/src/monitor_chooser.c
index 28f5c3a..05832a9 100644
--- a/src/monitor_chooser.c
+++ b/src/monitor_chooser.c
@@ -542,16 +542,16 @@ paint_monitor ( cairo_t *cr,
     {
         cairo_clip_preserve (cr);
 
-        hscale = width / (gdk_pixbuf_get_width(monitor->pixbuf));
-        vscale = height / (gdk_pixbuf_get_height(monitor->pixbuf));
+        hscale = monitor_width / (gdk_pixbuf_get_width(monitor->pixbuf));
+        vscale = monitor_height / (gdk_pixbuf_get_height(monitor->pixbuf));
 
         cairo_scale (cr, hscale, vscale);
 
         gdk_cairo_set_source_pixbuf (
                 cr,
                 monitor->pixbuf,
-                monitor_x,
-                monitor_y);
+                monitor_x/hscale,
+                monitor_y/vscale);
         cairo_paint(cr);
 
         cairo_reset_clip(cr);
diff --git a/src/xfce_wallpaper_manager.c b/src/xfce_wallpaper_manager.c
index 7f96dd3..1e42d0c 100644
--- a/src/xfce_wallpaper_manager.c
+++ b/src/xfce_wallpaper_manager.c
@@ -800,6 +800,7 @@ configure_monitor_chooser_pixbuf (
                         x_scale = y_scale;
                     }
                     break;
+                case MONITOR_STYLE_AUTOMATIC:
                 case MONITOR_STYLE_SCALED:
                     x_scale = (gdouble)pixbuf_width / (gdouble)gdk_pixbuf_get_width (tmp_pixbuf);
                     y_scale = (gdouble)pixbuf_height / (gdouble)gdk_pixbuf_get_height (tmp_pixbuf);
@@ -813,12 +814,10 @@ configure_monitor_chooser_pixbuf (
                     }
                     dest_width = x_scale * (gdouble)gdk_pixbuf_get_width (tmp_pixbuf);
                     dest_height = y_scale * (gdouble)gdk_pixbuf_get_height (tmp_pixbuf);
-                    dest_x = (gdouble)(dest_width - gdk_pixbuf_get_width (tmp_pixbuf)*x_scale) / 2;
-                    dest_y = (gdouble)(dest_height - gdk_pixbuf_get_height (tmp_pixbuf)*y_scale) / 2;
+                    dest_x = (gdouble)(pixbuf_width - gdk_pixbuf_get_width (tmp_pixbuf)*x_scale) / 2;
+                    dest_y = (gdouble)(pixbuf_height - gdk_pixbuf_get_height (tmp_pixbuf)*y_scale) / 2;
                     break;
-                case MONITOR_STYLE_AUTOMATIC:
                 case MONITOR_STYLE_STRETCHED:
-                default:
                     dest_x = 0;
                     dest_y = 0;
                     dest_width = pixbuf_width;
@@ -826,6 +825,26 @@ configure_monitor_chooser_pixbuf (
                     x_scale = (gdouble)dest_width / (gdouble)gdk_pixbuf_get_width (tmp_pixbuf);
                     y_scale = (gdouble)dest_height / (gdouble)gdk_pixbuf_get_height (tmp_pixbuf);
                     break;
+                default:
+                    x_scale = (gdouble)pixbuf_width / (gdouble)gdk_pixbuf_get_width (tmp_pixbuf);
+                    y_scale = (gdouble)pixbuf_height / (gdouble)gdk_pixbuf_get_height (tmp_pixbuf);
+                    if (x_scale > y_scale)
+                    {
+                        x_scale = y_scale;
+                    }
+                    else
+                    {
+                        y_scale = x_scale;
+                    }
+                    dest_width = x_scale * (gdouble)gdk_pixbuf_get_width (tmp_pixbuf);
+                    dest_height = y_scale * (gdouble)gdk_pixbuf_get_height (tmp_pixbuf);
+                    dest_x = (gdouble)(pixbuf_width - gdk_pixbuf_get_width (tmp_pixbuf)*x_scale) / 2;
+                    dest_y = (gdouble)(pixbuf_height - gdk_pixbuf_get_height (tmp_pixbuf)*y_scale) / 2;
+                    gdk_pixbuf_saturate_and_pixelate (
+                        tmp_pixbuf,
+                        tmp_pixbuf,
+                        0.0,
+                        TRUE);
             }
 
             gdk_pixbuf_composite (


More information about the Xfce4-commits mailing list