shithub: zuke

Download patch

ref: 5e005228889a1e62170f1cf66f9af0c5ebafe645
parent: 5627fda2586f9c4e53d0e316401aaa1937e34de8
author: Sigrid Haflínudóttir <ftrvxmtrx@gmail.com>
date: Thu Aug 13 07:21:19 EDT 2020

show where zuke would seek if the user would press on the seek bar

--- a/zuke.c
+++ b/zuke.c
@@ -62,6 +62,8 @@
 static char *cols = "AatD";
 static int *shuffle;
 static Rectangle seekbar;
+static int seekmx, newseekmx;
+static double seekoff; /* ms */
 static char *covers[] = {"folder", "cover", "Cover", "scans/CD", "Scans/Front", "Covers/Front"};
 
 static char *menu3i[] = {
@@ -252,9 +254,10 @@
 			msec = MIN(msec, getmeta(pcurplaying)->duration);
 			snprint(tmp, sizeof(tmp), "%s%P/%P %d%%",
 				shuffle != nil ? "∫ " : "",
-				(int)msec/1000,
+				(int)(newseekmx >= 0 ? seekoff : msec)/1000,
 				getmeta(pcurplaying)->duration/1000,
 				volume);
+			seekmx = newseekmx;
 		}else{
 			snprint(tmp, sizeof(tmp), "%s%P %d%%",
 				shuffle != nil ? "∫ " : "",
@@ -920,9 +923,20 @@
 	for(;;){
 ev:
 		oldpcur = pcur;
+		if(seekmx != newseekmx)
+			redraw(0);
 
 		switch(alt(a)){
 		case 0:
+			if(ptinrect(m.xy, seekbar)){
+				seekoff = getmeta(pcurplaying)->duration * (double)(m.xy.x-1-seekbar.min.x) / (double)Dx(seekbar);
+				if(seekoff < 0)
+					seekoff = 0;
+				newseekmx = m.xy.x-1;
+			}else{
+				newseekmx = -1;
+			}
+
 			if(m.buttons != 2)
 				scrolling = 0;
 			if(m.buttons == 0)
@@ -937,16 +951,15 @@
 				break;
 			}
 
-			n = (m.xy.y - screen->r.min.y)/f->height;
 
 			if(oldbuttons == 0 && !scrolling && ptinrect(m.xy, insetrect(seekbar, -4))){
-				m.xy.x--;
-				if(ptinrect(m.xy, seekbar)){
-					double off = getmeta(pcurplaying)->duration * (double)(m.xy.x-seekbar.min.x) / (double)Dx(seekbar);
-					seekrel(playercurr, off/1000.0 - byteswritten/Bps);
-				}
+				if(ptinrect(m.xy, seekbar))
+					seekrel(playercurr, seekoff/1000.0 - byteswritten/Bps);
 				break;
 			}
+
+			n = (m.xy.y - screen->r.min.y)/f->height;
+
 			if(oldbuttons == 0 && m.xy.x <= screen->r.min.x+Scrollwidth){
 				if(m.buttons == 1){
 					scroll = MAX(0, scroll-n-1);