mirror of
https://github.com/rust-windowing/winit.git
synced 2026-06-27 07:03:15 -04:00
Fix inverted horizontal scroll on macOS
In winit the swipe from left to right on touchpad should generate positive horizontal delta change, however on macOS it was the other way around without natural scrolling. This commit inverses the horizontal scrolling delta in 'MouseScrollDelta' events to match other platforms. Fixes #1695.
This commit is contained in:
@@ -1003,7 +1003,8 @@ extern "C" fn scroll_wheel(this: &Object, _sel: Sel, event: id) {
|
||||
let state = &mut *(state_ptr as *mut ViewState);
|
||||
|
||||
let delta = {
|
||||
let (x, y) = (event.scrollingDeltaX(), event.scrollingDeltaY());
|
||||
// macOS horizontal sign convention is the inverse of winit.
|
||||
let (x, y) = (event.scrollingDeltaX() * -1.0, event.scrollingDeltaY());
|
||||
if event.hasPreciseScrollingDeltas() == YES {
|
||||
let delta = LogicalPosition::new(x, y).to_physical(state.get_scale_factor());
|
||||
MouseScrollDelta::PixelDelta(delta)
|
||||
|
||||
Reference in New Issue
Block a user