shithub: picker

Download patch

ref: 2a853dc838b882d3eb0dc3f5bcb7cfad32baf416
parent: e6ae8d2002a6e790bb619335dabc530ad5cc425f
author: Sigrid Haflínudóttir <ftrvxmtrx@gmail.com>
date: Sat Mar 14 18:07:54 EDT 2020

print out new color only if it actually changed

--- a/picker.c
+++ b/picker.c
@@ -353,16 +353,21 @@
 					Rectangle r = srects[i];
 					r.max.x += 1;
 					if (ptinrect(m.xy, r)) {
+						ulong u;
+
 						c->v[i] = MIN(mode->max[i], (double)(m.xy.x - r.min.x) * mode->max[i]/(double)(Dx(r)-1));
 						mode->torgb(c->v, c->rgba);
-						c->u = D2C(c->rgba[0])<<24 | D2C(c->rgba[1])<<16 | D2C(c->rgba[2])<<8 | D2C(c->v[3]);
-						if (nchan < 4)
-							j = sprint(buf, "%d %06lux\n", curcolor, c->u>>8);
-						else
-							j = sprint(buf, "%d %08lux\n", curcolor, c->u);
-						if (write(1, buf, j) != j)
-							goto end;
-						redraw();
+						u = D2C(c->rgba[0])<<24 | D2C(c->rgba[1])<<16 | D2C(c->rgba[2])<<8 | D2C(c->v[3]);
+						if (c->u != u) {
+							c->u = u;
+							if (nchan < 4)
+								j = sprint(buf, "%d %06lux\n", curcolor, u>>8);
+							else
+								j = sprint(buf, "%d %08lux\n", curcolor, u);
+							if (write(1, buf, j) != j)
+								goto end;
+							redraw();
+						}
 						goto next;
 					}
 				}