cocoa: Don't round scroll deltas from trackpads
Rounding the scroll deltas from trackpads causes jerky scrolling behavior by artificially amplifying the effects of very small scroll movements. We should only round events from devices with discrete scroll wheels, because we know the smallest unit of movement there is a single tick.main
parent
8cee50eea5
commit
da0f76de6d
|
@ -473,6 +473,9 @@ Cocoa_HandleMouseWheel(SDL_Window *window, NSEvent *event)
|
|||
}
|
||||
}
|
||||
|
||||
/* 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 respondsToSelector:@selector(hasPreciseScrollingDeltas)] || ![event hasPreciseScrollingDeltas]) {
|
||||
if (x > 0) {
|
||||
x = SDL_ceil(x);
|
||||
} else if (x < 0) {
|
||||
|
@ -483,6 +486,7 @@ Cocoa_HandleMouseWheel(SDL_Window *window, NSEvent *event)
|
|||
} else if (y < 0) {
|
||||
y = SDL_floor(y);
|
||||
}
|
||||
}
|
||||
|
||||
SDL_SendMouseWheel(window, mouseID, x, y, direction);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue