@@ 62,6 62,8 @@ static int mincolwidth[7];
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 @@ redraw(int full)
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 @@ threadmain(int argc, char **argv)
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 @@ ev:
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);