From 6c2899a0ac4cec99809767f0678960547553d26c Mon Sep 17 00:00:00 2001 From: 0xmatthias Date: Mon, 6 Feb 2017 04:22:53 +0100 Subject: [PATCH 1/4] added --begin-top option to force view point at the top of the image --- src/help.raw | 1 + src/options.c | 4 ++++ src/options.h | 1 + src/winwidget.c | 7 ++++++- 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/help.raw b/src/help.raw index 067e35f9..516444e6 100644 --- a/src/help.raw +++ b/src/help.raw @@ -24,6 +24,7 @@ OPTIONS before attempting to display anything -., --scale-down Automatically scale down images to fit screen size -F, --fullscreen Make the window full screen + --begin-top Force view point at the top of the image -Z, --auto-zoom Zoom picture to screen size in fullscreen/geom mode --zoom PERCENT Zooms images by a PERCENT, when in full screen mode or when window geometry is fixed. If combined diff --git a/src/options.c b/src/options.c index 56323a81..3d6b3651 100644 --- a/src/options.c +++ b/src/options.c @@ -409,6 +409,7 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun) {"xinerama-index", 1, 0, 239}, {"insecure" , 0, 0, 240}, {"no-recursive" , 0, 0, 241}, + {"begin-top" , 0, 0, 242}, {0, 0, 0, 0} }; int optch = 0, cmdx = 0; @@ -770,6 +771,9 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun) opt.insecure_ssl = 1; case 241: opt.recursive = 0; + case 242: + opt.begin_top = 1; + break; default: break; } diff --git a/src/options.h b/src/options.h index 5a5ce846..aa3e3876 100644 --- a/src/options.h +++ b/src/options.h @@ -111,6 +111,7 @@ struct __fehoptions { unsigned int geom_h; int default_zoom; int zoom_mode; + int begin_top; unsigned char adjust_reload; int xinerama_index; diff --git a/src/winwidget.c b/src/winwidget.c index e92f1c3e..5efe717f 100644 --- a/src/winwidget.c +++ b/src/winwidget.c @@ -432,10 +432,12 @@ void winwidget_render_image(winwidget winwid, int resize, int force_alias) int antialias = 0; int need_center = winwid->had_resize; + /* Causes horrible "tearing" (render picture big/small if auto-zoom is on), + * if you switch fast between images (slideshow). if (!winwid->full_screen && resize) { winwidget_resize(winwid, winwid->im_w, winwid->im_h, 0); winwidget_reset_image(winwid); - } + }*/ /* bounds checks for panning */ if (winwid->im_x > winwid->w) @@ -563,6 +565,9 @@ void winwidget_render_image(winwidget winwid, int resize, int force_alias) && (winwid->type != WIN_TYPE_THUMBNAIL) && !opt.keep_zoom_vp) { winwid->im_x = (int) (winwid->w - (winwid->im_w * winwid->zoom)) >> 1; winwid->im_y = (int) (winwid->h - (winwid->im_h * winwid->zoom)) >> 1; + + if (opt.begin_top) + winwid->im_y = 0; } /* Now we ensure only to render the area we're looking at */ From c0cfcaeaba6fcebed8bfe734e863afc31e6fc479 Mon Sep 17 00:00:00 2001 From: 0xmatthias Date: Mon, 6 Feb 2017 22:26:02 +0100 Subject: [PATCH 2/4] do not enforce view top if image is smaller than window --- src/winwidget.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/winwidget.c b/src/winwidget.c index 5efe717f..1a3acf92 100644 --- a/src/winwidget.c +++ b/src/winwidget.c @@ -563,10 +563,14 @@ void winwidget_render_image(winwidget winwid, int resize, int force_alias) } else if (need_center && !winwid->full_screen && (winwid->type != WIN_TYPE_THUMBNAIL) && !opt.keep_zoom_vp) { + int smaller; winwid->im_x = (int) (winwid->w - (winwid->im_w * winwid->zoom)) >> 1; winwid->im_y = (int) (winwid->h - (winwid->im_h * winwid->zoom)) >> 1; - if (opt.begin_top) + smaller = ((winwid->im_w < winwid->w) + && (winwid->im_h < winwid->h)); + + if (!smaller && opt.begin_top) winwid->im_y = 0; } From 96a8e522baa40280424bcdc2182a56eeff8ce982 Mon Sep 17 00:00:00 2001 From: 0xmatthias Date: Sat, 3 Feb 2018 03:19:44 +0100 Subject: [PATCH 3/4] revert if-else case change --- src/winwidget.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/winwidget.c b/src/winwidget.c index 1a3acf92..f1b5e655 100644 --- a/src/winwidget.c +++ b/src/winwidget.c @@ -434,10 +434,11 @@ void winwidget_render_image(winwidget winwid, int resize, int force_alias) /* Causes horrible "tearing" (render picture big/small if auto-zoom is on), * if you switch fast between images (slideshow). + */ if (!winwid->full_screen && resize) { winwidget_resize(winwid, winwid->im_w, winwid->im_h, 0); winwidget_reset_image(winwid); - }*/ + } /* bounds checks for panning */ if (winwid->im_x > winwid->w) From 4ec93c29f8c9c45678471a8d388756abff7fdbdf Mon Sep 17 00:00:00 2001 From: 0xmatthias Date: Mon, 5 Mar 2018 21:01:29 +0100 Subject: [PATCH 4/4] removed static-window --- src/winwidget.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/winwidget.c b/src/winwidget.c index f1b5e655..233acda6 100644 --- a/src/winwidget.c +++ b/src/winwidget.c @@ -432,9 +432,6 @@ void winwidget_render_image(winwidget winwid, int resize, int force_alias) int antialias = 0; int need_center = winwid->had_resize; - /* Causes horrible "tearing" (render picture big/small if auto-zoom is on), - * if you switch fast between images (slideshow). - */ if (!winwid->full_screen && resize) { winwidget_resize(winwid, winwid->im_w, winwid->im_h, 0); winwidget_reset_image(winwid); @@ -564,14 +561,14 @@ void winwidget_render_image(winwidget winwid, int resize, int force_alias) } else if (need_center && !winwid->full_screen && (winwid->type != WIN_TYPE_THUMBNAIL) && !opt.keep_zoom_vp) { - int smaller; + int image_smaller; winwid->im_x = (int) (winwid->w - (winwid->im_w * winwid->zoom)) >> 1; winwid->im_y = (int) (winwid->h - (winwid->im_h * winwid->zoom)) >> 1; - smaller = ((winwid->im_w < winwid->w) + image_smaller = ((winwid->im_w < winwid->w) && (winwid->im_h < winwid->h)); - if (!smaller && opt.begin_top) + if (!image_smaller && opt.begin_top) winwid->im_y = 0; }