From efc06f6cc780b766a703c5dab4bcecae01bb7a27 Mon Sep 17 00:00:00 2001 From: Richard Hestilow Date: Wed, 20 Jun 2001 16:36:01 +0000 Subject: [PATCH] Handle properly the case where centered/tiled image is larger than the 2001-06-20 Richard Hestilow * capplets/new-background-properties/applicer.c (get_geometry): Handle properly the case where centered/tiled image is larger than the screen/preview. --- ChangeLog | 6 ++++++ capplets/background/applier.c | 20 ++++++++++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 888989178..483d43a29 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2001-06-20 Richard Hestilow + + * capplets/new-background-properties/applicer.c + (get_geometry): Handle properly the case where centered/tiled + image is larger than the screen/preview. + 2001-06-20 Bradford Hovinen * capplets/new-background-properties/applier.c diff --git a/capplets/background/applier.c b/capplets/background/applier.c index 13fd97f2c..61954c2fb 100644 --- a/capplets/background/applier.c +++ b/capplets/background/applier.c @@ -1084,35 +1084,43 @@ get_geometry (wallpaper_type_t wallpaper_type, GdkPixbuf *pixbuf, else factor = 1.0; - *rwidth = gdk_pixbuf_get_width (pixbuf) * factor; - /* wallpaper_type could be WPTYPE_TILED too */ if (vwidth < gdk_pixbuf_get_width (pixbuf) && wallpaper_type == WPTYPE_CENTERED) + { *srcx = (gdk_pixbuf_get_width (pixbuf) - vwidth) * factor / 2; + *rwidth = dwidth; + } else + { *srcx = 0; + *rwidth = gdk_pixbuf_get_width (pixbuf) * factor; + } if (dheight != vheight) factor = (gdouble) dheight / (gdouble) vheight; else factor = 1.0; - *rheight = gdk_pixbuf_get_height (pixbuf) * factor; - /* wallpaper_type could be WPTYPE_TILED too */ if (vheight < gdk_pixbuf_get_height (pixbuf) && wallpaper_type == WPTYPE_CENTERED) + { *srcy = (gdk_pixbuf_get_height (pixbuf) - vheight) * factor / 2; + *rheight = dheight; + } else + { *srcy = 0; + *rheight = gdk_pixbuf_get_height (pixbuf) * factor; + } /* wallpaper_type could be WPTYPE_TILED too */ if (wallpaper_type == WPTYPE_CENTERED) { - *xoffset = (dwidth - *rwidth) >> 1; - *yoffset = (dheight - *rheight) >> 1; + *xoffset = MAX ((dwidth - *rwidth) >> 1, 0); + *yoffset = MAX ((dheight - *rheight) >> 1, 0); } break;