Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions man/feh.pre
Original file line number Diff line number Diff line change
Expand Up @@ -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
.
Expand Down
36 changes: 15 additions & 21 deletions src/slideshow.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
}
Expand Down
Loading