From d762c291de038bb85f1bbbe27297b8bd1291a144 Mon Sep 17 00:00:00 2001 From: Eric Lammerts Date: Thu, 16 Apr 2026 14:17:07 -0400 Subject: [PATCH] Make --on-last-slide=hold work for PageUp/PageDown --- man/feh.pre | 2 -- src/slideshow.c | 36 +++++++++++++++--------------------- 2 files changed, 15 insertions(+), 23 deletions(-) diff --git a/man/feh.pre b/man/feh.pre index f781daa7..a3594348 100644 --- a/man/feh.pre +++ b/man/feh.pre @@ -670,8 +670,6 @@ With will stop advancing images in this case and continue displaying the first/last image, respectively. This is intended for linear slide shows. -Behaviour is unspecified when using other navigation commands than previous -and next image. . .Pp . diff --git a/src/slideshow.c b/src/slideshow.c index c25d0b7e..427a2c11 100644 --- a/src/slideshow.c +++ b/src/slideshow.c @@ -194,7 +194,6 @@ void cb_reload_timer(void *data) void slideshow_change_image(winwidget winwid, int change, int render) { gib_list *last = NULL; - gib_list *previous_file = current_file; int i = 0; int jmp = 1; /* We can't use filelist_len in the for loop, since that changes when we @@ -210,20 +209,6 @@ void slideshow_change_image(winwidget winwid, int change, int render) if (filelist_len < 2 && opt.on_last_slide != ON_LAST_SLIDE_QUIT) return; - /* Ok. I do this in such an odd way to ensure that if the last or first * - image is not loadable, it will go through in the right direction to * - find the correct one. Otherwise SLIDE_LAST would try the last file, * - then loop forward to find a loadable one. */ - if (change == SLIDE_FIRST) { - current_file = gib_list_last(filelist); - change = SLIDE_NEXT; - previous_file = NULL; - } else if (change == SLIDE_LAST) { - current_file = filelist; - change = SLIDE_PREV; - previous_file = NULL; - } - /* The for loop prevents us looping infinitely */ for (i = 0; i < our_filelist_len; i++) { winwidget_free_image(winwid); @@ -240,6 +225,16 @@ void slideshow_change_image(winwidget winwid, int change, int render) } #endif switch (change) { + case SLIDE_FIRST: + current_file = filelist; + /* important. if the load fails, we want to try the next file */ + change = SLIDE_NEXT; + break; + case SLIDE_LAST: + current_file = gib_list_last(filelist); + /* important. if the load fails, we want to try the previous file */ + change = SLIDE_PREV; + break; case SLIDE_NEXT: current_file = feh_list_jump(filelist, current_file, FORWARD, 1); break; @@ -329,12 +324,6 @@ void slideshow_change_image(winwidget winwid, int change, int render) last = NULL; } - if (opt.on_last_slide == ON_LAST_SLIDE_HOLD && previous_file && - ((current_file == filelist && change == SLIDE_NEXT) || - (previous_file == filelist && change == SLIDE_PREV))) { - current_file = previous_file; - } - if (winwidget_loadimage(winwid, FEH_FILE(current_file->data))) { int w = gib_imlib_image_get_width(winwid->im); int h = gib_imlib_image_get_height(winwid->im); @@ -703,6 +692,9 @@ gib_list *feh_list_jump(gib_list * root, gib_list * l, int direction, int num) if (opt.on_last_slide == ON_LAST_SLIDE_QUIT) { exit(0); } + if(opt.on_last_slide == ON_LAST_SLIDE_HOLD) { + break; + } if (opt.randomize) { /* Randomize the filename order */ filelist = gib_list_randomize(filelist); @@ -714,6 +706,8 @@ gib_list *feh_list_jump(gib_list * root, gib_list * l, int direction, int num) } else { if (ret->prev) ret = ret->prev; + else if(opt.on_last_slide == ON_LAST_SLIDE_HOLD) + break; else ret = gib_list_last(ret); }