Skip to content

Commit

Permalink
Fix inverted horizontal scroll on macOS
Browse files Browse the repository at this point in the history
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 rust-windowing#1695.
  • Loading branch information
michaelkirk authored Sep 6, 2020
1 parent 658a9a4 commit e2cf2a5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
- On NetBSD, fixed crash due to incorrect detection of the main thread.
- **Breaking:** The virtual key code `Subtract` has been renamed to `NumpadSubtract`
- **Breaking:** On X11, `-` key is mapped to the `Minus` virtual key code, instead of `Subtract`
- On macOS, fix inverted horizontal scroll.

# 0.22.2 (2020-05-16)

Expand Down
3 changes: 2 additions & 1 deletion src/platform_impl/macos/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e2cf2a5

Please sign in to comment.