From 0e0c003ddb991d11c3253ff74ab386dc5534a08f Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 17 Mar 2021 08:00:28 +0000 Subject: Incorporate Csaba's suggestion: Timeout to 300ms (was 1.5s). And after timeout occurred, always jump at least 120 in the first mousewheel move --- macosx/tkMacOSXMouseEvent.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/macosx/tkMacOSXMouseEvent.c b/macosx/tkMacOSXMouseEvent.c index c792a90..3c61620 100644 --- a/macosx/tkMacOSXMouseEvent.c +++ b/macosx/tkMacOSXMouseEvent.c @@ -333,15 +333,19 @@ enum { xEvent.xany.window = Tk_WindowId(target); #define WHEEL_DELTA 120 -#define WHEEL_DELAY 1500000000 +#define WHEEL_DELAY 300000000 uint64_t wheelTick = clock_gettime_nsec_np(CLOCK_MONOTONIC_RAW); - if (wheelTick - tsdPtr->wheelTickPrev >= WHEEL_DELAY) { + int timeout = (wheelTick - tsdPtr->wheelTickPrev) >= WHEEL_DELAY; + if (timeout) { tsdPtr->vWheelAcc = tsdPtr->hWheelAcc = 0; } tsdPtr->wheelTickPrev = wheelTick; delta = [theEvent deltaY]; if (delta != 0.0) { delta = (tsdPtr->vWheelAcc += delta); + if (timeout && fabs(delta) < 1.0) { + delta = ((delta < 0.0) ? -1.0 : 1.0); + } if (fabs(delta) >= 0.6) { xEvent.xbutton.state = state; xEvent.xkey.keycode = WHEEL_DELTA * round(delta); @@ -353,6 +357,9 @@ enum { delta = [theEvent deltaX]; if (delta != 0.0) { delta = (tsdPtr->hWheelAcc += delta); + if (timeout && fabs(delta) < 1.0) { + delta = ((delta < 0.0) ? -1.0 : 1.0); + } if (fabs(delta) >= 0.6) { xEvent.xbutton.state = state | ShiftMask; xEvent.xkey.keycode = WHEEL_DELTA * round(delta); -- cgit v0.12