[Bf-blender-cvs] [ad7588600c3] temp-cocoa-scroll-acceleration-fix: Bring back pre 2.8 scrolling acceleration

Julian Eisel noreply at git.blender.org
Wed Sep 15 15:50:08 CEST 2021


Commit: ad7588600c35423b2908756afd694331f08aeb20
Author: Julian Eisel
Date:   Wed Sep 15 15:46:48 2021 +0200
Branches: temp-cocoa-scroll-acceleration-fix
https://developer.blender.org/rBad7588600c35423b2908756afd694331f08aeb20

Bring back pre 2.8 scrolling acceleration

Up until the 2.79 release, we'd use our own acceleration method for scrolling
on macOS. Since then we rely on macOS to do this for us, but turns out it does
a worse job, at least for our needs. This is an experiment to bring the old
behavior back.

===================================================================

M	intern/ghost/intern/GHOST_SystemCocoa.mm

===================================================================

diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm
index 189e663f91a..e3b33e40283 100644
--- a/intern/ghost/intern/GHOST_SystemCocoa.mm
+++ b/intern/ghost/intern/GHOST_SystemCocoa.mm
@@ -1708,16 +1708,42 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
         double dx;
         double dy;
 
-        /* with 10.7 nice scrolling deltas are supported */
-        dx = [event scrollingDeltaX];
-        dy = [event scrollingDeltaY];
-
-        /* However, Wacom tablet (intuos5) needs old deltas,
-         * it then has momentum and phase at zero. */
-        if (phase == NSEventPhaseNone && momentumPhase == NSEventPhaseNone) {
-          dx = [event deltaX];
-          dy = [event deltaY];
+        /* trying to pretend you have nice scrolls... */
+        dx = [event deltaX];
+        dy = [event deltaY];
+        if ((dx == 0) && (dy == 0))
+          break;
+
+        const double deltaMax = 50.0;
+        /* Quadratic acceleration */
+        dx = dx * (fabs(dx) + 0.5);
+        if (dx < 0.0) {
+          dx -= 0.5;
+        }
+        else {
+          dx += 0.5;
         }
+        if (dx < -deltaMax) {
+          dx = -deltaMax;
+        }
+        else if (dx > deltaMax) {
+          dx = deltaMax;
+        }
+
+        dy = dy * (fabs(dy) + 0.5);
+        if (dy < 0.0) {
+          dy -= 0.5;
+        }
+        else {
+          dy += 0.5;
+        }
+        if (dy < -deltaMax) {
+          dy = -deltaMax;
+        }
+        else if (dy > deltaMax) {
+          dy = deltaMax;
+        }
+
         window->clientToScreenIntern(mousePos.x, mousePos.y, x, y);
 
         NSPoint delta = [[cocoawindow contentView] convertPointToBacking:NSMakePoint(dx, dy)];



More information about the Bf-blender-cvs mailing list