Krolyxon
Commit 450797c

Branches

Refs →

nsxiv450797c

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.
Author
N-R-K
Date
2022-05-28 06:48 +0000
Committer
GitHub · 2022-05-28 06:48 +0000
Parent
b4268fb
Commit
450797c573ef4ae42e93de5571319a5318142df9

+1 −1

1 file changed

  1. M main.c +1 −1
M main.c View
@@ -88,8 +88,8 @@ static struct {
8888 static timeout_t timeouts[] = {
8989 { { 0, 0 }, false, redraw },
9090 { { 0, 0 }, false, reset_cursor },
91− { { 0, 0 }, false, animate },
9291 { { 0, 0 }, false, slideshow },
92+ { { 0, 0 }, false, animate },
9393 { { 0, 0 }, false, clear_resize },
9494 };
9595