Merge pull request #718 from paulrouget/hidpiwheel

osx: scroll delta should take hidpi factor into account
This commit is contained in:
tomaka 2016-02-02 10:53:11 +01:00
commit b63070db25

View file

@ -881,10 +881,13 @@ unsafe fn NSEventToEvent(window: &Window, nsevent: id) -> Option<Event> {
},
NSScrollWheel => {
use events::MouseScrollDelta::{LineDelta, PixelDelta};
let scale_factor = window.hidpi_factor();
let delta = if nsevent.hasPreciseScrollingDeltas() == YES {
PixelDelta(nsevent.scrollingDeltaX() as f32, nsevent.scrollingDeltaY() as f32)
PixelDelta(scale_factor * nsevent.scrollingDeltaX() as f32,
scale_factor * nsevent.scrollingDeltaY() as f32)
} else {
LineDelta(nsevent.scrollingDeltaX() as f32, nsevent.scrollingDeltaY() as f32)
LineDelta(scale_factor * nsevent.scrollingDeltaX() as f32,
scale_factor * nsevent.scrollingDeltaY() as f32)
};
Some(MouseWheel(delta))
},