From ae23674f215fb29dcef0b432f6a3bc489b54926d Mon Sep 17 00:00:00 2001 From: "Geoffrey D. Bennett" Date: Wed, 26 Feb 2025 02:07:20 +1030 Subject: [PATCH] Add small deadband to dial drag to stop double-click adjustments Sometimes 0.5 < abs(offset_y) < 1 when double-clicking without moving the mouse, causing the intended toggling between -inf and 0dB to not work. Fixes: #149. --- src/gtkdial.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/gtkdial.c b/src/gtkdial.c index 6a0beed..9628cf0 100644 --- a/src/gtkdial.c +++ b/src/gtkdial.c @@ -1496,6 +1496,19 @@ static void gtk_dial_drag_gesture_update( double valp; + // add a 1px deadband to prevent double-click with zero mouse + // movement from changing the value from the toggled -inf/0dB value + // (sometimes we see an offset_y value that rounds to +/- 1 which + // causes the value to change after the double-click has set the + // value) + if (offset_y < -1) { + offset_y += 1; + } else if (offset_y < 1) { + offset_y = 0; + } else { + offset_y -= 1; + } + if (is_linear) { double step = gtk_adjustment_get_step_increment(dial->adj);