shithub: zuke

Download patch

ref: 5756ecf17937f697444fe02f6b13a205a78a975c
parent: 9661ba1a2fecaef64ce88fc360f5ad306d0a8de8
author: Sigrid Haflínudóttir <ftrvxmtrx@gmail.com>
date: Wed Aug 12 18:31:14 EDT 2020

simplify current position logic in drawing

--- a/zuke.c
+++ b/zuke.c
@@ -245,17 +245,20 @@
 		}
 	}
 
+	vlong msec = 0;
 	if(pcurplaying >= 0){
+		msec = byteswritten*1000/Bps;
 		if(getmeta(pcurplaying)->duration != 0){
+			msec = MIN(msec, getmeta(pcurplaying)->duration);
 			snprint(tmp, sizeof(tmp), "%s%P/%P %d%%",
 				shuffle != nil ? "∫ " : "",
-				(int)(byteswritten/Bps),
+				(int)msec/1000,
 				getmeta(pcurplaying)->duration/1000,
 				volume);
 		}else{
 			snprint(tmp, sizeof(tmp), "%s%P %d%%",
 				shuffle != nil ? "∫ " : "",
-				(int)(byteswritten/Bps),
+				(int)msec/1000,
 				volume);
 		}
 	}else
@@ -291,7 +294,7 @@
 		draw(screen, r, colors[Dfmed].im, nil, ZP);
 		r = insetrect(r, 1);
 		seekbar = r;
-		r.max.x = r.min.x + Dx(r) * 1000.0*(double)byteswritten/Bps / (double)getmeta(pcurplaying)->duration;
+		r.max.x = r.min.x + Dx(r) * (double)msec / (double)getmeta(pcurplaying)->duration;
 		draw(screen, r, colors[Dbinv].im, nil, ZP);
 	}