Commit 4fb72f16 authored by Ilion Beyst's avatar Ilion Beyst
Browse files

Make --scale-down work with --geometry.

parent 89256a02
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -525,7 +525,9 @@ E.g. to sort in reverse width order, use
.
.It Cm -. , --scale-down
.
When not in fullscreen: Scale images to screen size if they are too big.
Scale images to fit window geometry (defaults to screen size when no geometry
was specified).
This option is ignored when in fullscreen mode.
.
.Pp
.
+33 −22
Original line number Diff line number Diff line
@@ -408,17 +408,27 @@ void winwidget_render_image(winwidget winwid, int resize, int force_alias)

	winwidget_setup_pixmaps(winwid);

	if (!winwid->full_screen && opt.scale_down && ((winwid->w < winwid->im_w)
						       || (winwid->h < winwid->im_h)) &&
	if (!winwid->full_screen && opt.scale_down &&
							  (winwid->type != WIN_TYPE_THUMBNAIL) &&
							  (winwid->old_zoom == 1.0)) {
		D(("scaling down image %dx%d\n", winwid->w, winwid->h));
        int max_w = winwid->w, max_h = winwid->h;
        if (opt.geom_flags & WidthValue) {
            max_w = opt.geom_w;
        }
        if (opt.geom_flags & HeightValue) {
            max_h = opt.geom_h;
        }
        D(("max: %dx%d, size: %dx%d\n", max_w, max_h, winwid->im_w, winwid->im_h));
        if (max_w < winwid->im_w || max_h < winwid->im_h) {
            D(("scaling down image %dx%d\n", max_w, max_h));

		feh_calc_needed_zoom(&(winwid->zoom), winwid->im_w, winwid->im_h, winwid->w, winwid->h);
            feh_calc_needed_zoom(&(winwid->zoom), winwid->im_w, winwid->im_h,
                    max_w, max_h);
            if (resize)
                winwidget_resize(winwid, winwid->im_w * winwid->zoom, winwid->im_h * winwid->zoom);
            D(("after scaling down image %dx%d\n", winwid->w, winwid->h));
        }
	}

	if (!winwid->full_screen && ((gib_imlib_image_has_alpha(winwid->im))
				     || (opt.geom_flags & (WidthValue | HeightValue))
@@ -433,7 +443,8 @@ void winwidget_render_image(winwidget winwid, int resize, int force_alias)
		feh_calc_needed_zoom(&(winwid->zoom), winwid->im_w, winwid->im_h, winwid->w, winwid->h);


	if (resize && (winwid->full_screen || (opt.geom_flags & (WidthValue | HeightValue)))) {
	if (resize && !opt.scale_down && (winwid->full_screen
                     || (opt.geom_flags & (WidthValue | HeightValue)))) {
		int smaller;	/* Is the image smaller than screen? */
		int max_w = 0, max_h = 0;

@@ -827,7 +838,7 @@ void winwidget_resize(winwidget winwid, int w, int h)
	D(("   x %d y %d w %d h %d\n", attributes.x, attributes.y, winwid->w,
		winwid->h));

	if (opt.geom_flags & (WidthValue | HeightValue)) {
    if (!opt.scale_down && opt.geom_flags & (WidthValue | HeightValue)) {
        winwid->had_resize = 1;
        return;
    }