emreyolcu / discrete-scroll

Fix for macOS's unnecessary scroll wheel acceleration
MIT License
809 stars 83 forks source link

Adaptive line scroll #3

Closed kmikiy closed 7 years ago

kmikiy commented 7 years ago

Hi, first of all I'd like to thank you for creating and sharing this app 😊 This "feature" in sierra has been driving me crazy for the last two months.

I was wondering if you could add an option to only scroll one line when the scroll wheel ticks once, but scroll multiple lines if the scroll wheel ticks multiple times in for example a 0.2 second time window.

I'd like this feature because it would help when viewing a pdf with Quick Look. If the scroll is set to three lines then on a scroll wheel tick the document would scroll down 3 pages, when in reality I only want to scroll down one page. But if I use the release where you set the scroll to 1 line, then thats a little bit inconvenient when scrolling in any other app on a daily basis.

Thank you for your help in advance! Regards, Kmikiy

thomasst commented 7 years ago

10.12.2 fixes scrolling behavior for me, but this did the trick for me in 10.12.1:

diff --git a/DiscreteScroll/main.m b/DiscreteScroll/main.m
index bddf9a4..36c8fe8 100644
--- a/DiscreteScroll/main.m
+++ b/DiscreteScroll/main.m
@@ -7,9 +7,12 @@ CGEventRef cgEventCallback(CGEventTapProxy proxy, CGEventType type,
                            CGEventRef event, void *refcon)
 {
     if (!CGEventGetIntegerValueField(event, kCGScrollWheelEventIsContinuous)) {
-        int64_t delta = CGEventGetIntegerValueField(event, kCGScrollWheelEventPointDeltaAxis1);
-
-        CGEventSetIntegerValueField(event, kCGScrollWheelEventDeltaAxis1, SIGN(delta) * LINES);
+        if (CGEventGetIntegerValueField(event, kCGScrollWheelEventDeltaAxis1) == 0) {
+            int64_t delta = CGEventGetIntegerValueField(event, kCGScrollWheelEventPointDeltaAxis1);
+            if (delta != 0) {
+                CGEventSetIntegerValueField(event, kCGScrollWheelEventDeltaAxis1, SIGN(delta) * LINES);
+            }
+        }
     }

     return event;
kmikiy commented 7 years ago

Thanks @thomasst 10.12.2 solved it for me too :)