cocoa: restore discrete mouse wheel ticks

(cherry picked from commit 1f3f714393)
This commit is contained in:
Isabella Basso
2026-07-06 17:13:04 -03:00
committed by Ryan C. Gordon
parent b18591f4a0
commit 27e6b7a119

View File

@@ -618,17 +618,18 @@ void Cocoa_HandleMouseWheel(SDL_Window *window, NSEvent *event)
SDL_MouseWheelDirection direction;
CGFloat x, y;
x = -[event deltaX];
y = [event deltaY];
direction = SDL_MOUSEWHEEL_NORMAL;
if ([event isDirectionInvertedFromDevice] == YES) {
direction = SDL_MOUSEWHEEL_FLIPPED;
}
/* For discrete scroll events from conventional mice, always send a full tick.
For continuous scroll events from trackpads, send fractional deltas for smoother scrolling. */
if (![event hasPreciseScrollingDeltas]) {
if ([event hasPreciseScrollingDeltas]) {
x = -[event scrollingDeltaX] * 0.1f;
y = [event scrollingDeltaY] * 0.1f;
} else {
x = -[event deltaX];
y = [event deltaY];
if (x > 0) {
x = SDL_ceil(x);
} else if (x < 0) {