From 450797c573ef4ae42e93de5571319a5318142df9 Mon Sep 17 00:00:00 2001 From: N-R-K Date: Sat, 28 May 2022 06:48:44 +0000 Subject: [PATCH] fix: broken slideshow if redraw takes too long (#282) currently the way check_timeout() is implemented, animate has higher priority than slideshow. so if doing a redraw takes longer than the frame delay of the animated image then it's going to continuously keep animating and never reliably get to slideshow. this issue can occur if the animated image has too fast of a delay or if nsxiv is being run on a slow system where doing redraw takes too long. the issue can be emulated by artificially slowing down img_render by sticking a sleep in there. diff --git a/main.c b/main.c index 5dc52d4..0580011 100644 --- a/main.c +++ b/main.c @@ -441,6 +441,7 @@ void redraw(void) if (mode == MODE_IMAGE) { img_render(&img); + nanosleep(&(struct timespec){0, 62000000}, NULL); /* 62ms */ if (img.ss.on) { t = img.ss.delay * 100; if (img.multi.cnt > 0 && img.multi.animate) make it so that slideshow has higher priority than animate to fix the issue. Closes: https://github.com/nsxiv/nsxiv/issues/281 --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index 7c27f96..5dc52d4 100644 --- a/main.c +++ b/main.c @@ -88,8 +88,8 @@ static struct { static timeout_t timeouts[] = { { { 0, 0 }, false, redraw }, { { 0, 0 }, false, reset_cursor }, - { { 0, 0 }, false, animate }, { { 0, 0 }, false, slideshow }, + { { 0, 0 }, false, animate }, { { 0, 0 }, false, clear_resize }, };