1
1

Compare commits

...

2 Commits

Author SHA1 Message Date
da9be470b5 Merge branch 'master' into temp-cocoa-scroll-acceleration-fix 2021-09-15 22:34:20 +02:00
ad7588600c 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.
2021-09-15 15:46:48 +02:00

View File

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