render/cursor: Don't crash for themes with zero delay

This commit is contained in:
Victoria Brekenfeld 2024-06-27 16:41:38 +02:00
parent da9af7ad23
commit 16691581ff

View file

@ -115,10 +115,15 @@ fn nearest_images(size: u32, images: &[Image]) -> impl Iterator<Item = &Image> {
fn frame(mut millis: u32, size: u32, images: &[Image]) -> Image {
let total = nearest_images(size, images).fold(0, |acc, image| acc + image.delay);
millis %= total;
if total == 0 {
millis = 0;
} else {
millis %= total;
}
for img in nearest_images(size, images) {
if millis < img.delay {
if millis <= img.delay {
return img.clone();
}
millis -= img.delay;