diff options
author | Ilion Beyst <ilion.beyst@gmail.com> | 2015-01-05 04:30:35 +0100 |
---|---|---|
committer | Ilion Beyst <ilion.beyst@gmail.com> | 2015-01-09 13:58:32 +0100 |
commit | 4fb72f163060cf7d9663b64e535401f47e395151 (patch) | |
tree | 4ba81ea4e163e30427a216f56767f03a67095bd8 | |
parent | 89256a02f51edc44b556f759998eadfd8cf01b17 (diff) |
Make --scale-down work with --geometry.
-rw-r--r-- | man/feh.pre | 4 | ||||
-rw-r--r-- | src/winwidget.c | 55 |
2 files changed, 36 insertions, 23 deletions
diff --git a/man/feh.pre b/man/feh.pre index 4906158..a9f9894 100644 --- a/man/feh.pre +++ b/man/feh.pre @@ -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 . diff --git a/src/winwidget.c b/src/winwidget.c index 01bb454..a1b78d3 100644 --- a/src/winwidget.c +++ b/src/winwidget.c @@ -408,16 +408,26 @@ 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)); - - feh_calc_needed_zoom(&(winwid->zoom), winwid->im_w, winwid->im_h, winwid->w, winwid->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)); + 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, + 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)) @@ -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,24 +838,24 @@ 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)) { - winwid->had_resize = 1; - return; - } + if (!opt.scale_down && opt.geom_flags & (WidthValue | HeightValue)) { + winwid->had_resize = 1; + return; + } if (winwid && ((winwid->w != w) || (winwid->h != h))) { /* winwidget_clear_background(winwid); */ if (opt.screen_clip) { - winwid->w = (w > scr_width) ? scr_width : w; - winwid->h = (h > scr_height) ? scr_height : h; + winwid->w = (w > scr_width) ? scr_width : w; + winwid->h = (h > scr_height) ? scr_height : h; } if (winwid->full_screen) { - XTranslateCoordinates(disp, winwid->win, attributes.root, - -attributes.border_width - - attributes.x, - -attributes.border_width - attributes.y, &tc_x, &tc_y, &dw); - winwid->x = tc_x; - winwid->y = tc_y; - XMoveResizeWindow(disp, winwid->win, tc_x, tc_y, winwid->w, winwid->h); + XTranslateCoordinates(disp, winwid->win, attributes.root, + -attributes.border_width - + attributes.x, + -attributes.border_width - attributes.y, &tc_x, &tc_y, &dw); + winwid->x = tc_x; + winwid->y = tc_y; + XMoveResizeWindow(disp, winwid->win, tc_x, tc_y, winwid->w, winwid->h); } else XResizeWindow(disp, winwid->win, winwid->w, winwid->h); |