shithub: picker

Download patch

ref: e78c28ef5c5b1689a58a1696ff7d160630f1345e
parent: b457388fd65edc971034a534c306e269ccf604d7
author: Sigrid Haflínudóttir <ftrvxmtrx@gmail.com>
date: Mon Apr 13 08:16:46 EDT 2020

stay on the same slider when holding left button

--- a/picker.c
+++ b/picker.c
@@ -475,7 +475,7 @@
 		[Cresize] = { nil, nil, CHANRCV },
 		{ nil, nil, CHANEND },
 	};
-	int i, once;
+	int i, once, oldbuttons, slider;
 	ulong u;
 	char buf[16];
 
@@ -533,6 +533,7 @@
 	unlockdisplay(display);
 	loadbg();
 	redraw();
+	slider = -1;
 
 	proccreate(plumbproc, nil, mainstacksize);
 
@@ -539,6 +540,7 @@
 	for (;;) {
 next:
 		c = color;
+		oldbuttons = m.buttons;
 
 		switch (alt(a)) {
 		case -1:
@@ -567,7 +569,9 @@
 				for (i = 0; i < c->nchan; i++) {
 					Rectangle r = srects[i];
 					r.max.x += 1;
-					if (!ptinrect(m.xy, r))
+					if (oldbuttons == 0 && ptinrect(m.xy, r))
+						slider = i;
+					if (slider != i)
 						continue;
 
 					c->v[i] = MIN(space->max[i], (double)(m.xy.x - r.min.x) * space->max[i]/(double)(Dx(r)-1));
@@ -620,6 +624,7 @@
 					}
 				}
 			}
+			slider = -1;
 			break;
 
 		case Cresize: