summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ggamma.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/ggamma.c b/ggamma.c
index 3373be2..ac4eb35 100644
--- a/ggamma.c
+++ b/ggamma.c
@@ -19,12 +19,18 @@ struct gamma_channel {
void curve_edited(GtkWidget *raw_curve, UNUSED GdkEvent *event, struct gamma_channel *gamma) {
gfloat vec[gamma->size];
+ gboolean dirty = FALSE;
gtk_curve_get_vector(GTK_CURVE(raw_curve), gamma->size, vec);
- for (int i = 0; i < gamma->size; i++)
- gamma->data[i] = (uint16_t)(vec[i] * 65535.0 / gamma->size);
+ for (int i = 0; i < gamma->size; i++) {
+ uint16_t y = vec[i] * 65535.0 / gamma->size;
+ if (y != gamma->data[i]) {
+ gamma->data[i] = y;
+ dirty = TRUE;
+ }
+ }
- if (gamma->flush)
+ if (dirty && gamma->flush)
gamma->flush();
}