mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-06-06 06:34:35 +00:00
Reapply "MacOS: improve scroll smoothing"
This reverts commit 63c0650321.
This reverts a revert; leaving this in main, where we'll examine it in 3.6.0.
This remains reverted in release-3.4.x
Reference Issue #15058.
This commit is contained in:
parent
0f2d415dee
commit
c043adaeb2
1 changed files with 5 additions and 15 deletions
|
|
@ -618,27 +618,17 @@ void Cocoa_HandleMouseWheel(SDL_Window *window, NSEvent *event)
|
|||
SDL_MouseWheelDirection direction;
|
||||
CGFloat x, y;
|
||||
|
||||
x = -[event deltaX];
|
||||
y = [event deltaY];
|
||||
x = -[event scrollingDeltaX];
|
||||
y = [event scrollingDeltaY];
|
||||
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 (x > 0) {
|
||||
x = SDL_ceil(x);
|
||||
} else if (x < 0) {
|
||||
x = SDL_floor(x);
|
||||
}
|
||||
if (y > 0) {
|
||||
y = SDL_ceil(y);
|
||||
} else if (y < 0) {
|
||||
y = SDL_floor(y);
|
||||
}
|
||||
if ([event hasPreciseScrollingDeltas]) {
|
||||
x *= 0.1;
|
||||
y *= 0.1;
|
||||
}
|
||||
|
||||
SDL_SendMouseWheel(Cocoa_GetEventTimestamp([event timestamp]), window, mouseID, x, y, direction);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue