aboutsummaryrefslogtreecommitdiffstats
path: root/src/api/cocoa
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2016-03-02 16:13:13 -0800
committerJack Moffitt <jack@metajack.im>2016-03-03 16:49:35 -0700
commit7886ff9acdbc4961359725536c1a15e2cbb3d4f5 (patch)
tree1243ddf9e5b337b0b8ad91eabc269ce429072a4b /src/api/cocoa
parent2638db665afc175cf128c3e25bc883f4c114bb5a (diff)
downloadglutin-7886ff9acdbc4961359725536c1a15e2cbb3d4f5.tar.gz
glutin-7886ff9acdbc4961359725536c1a15e2cbb3d4f5.zip
Add phases to wheel events.
Needed for apps to support overscroll on the Mac.
Diffstat (limited to 'src/api/cocoa')
-rw-r--r--src/api/cocoa/mod.rs13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/api/cocoa/mod.rs b/src/api/cocoa/mod.rs
index abcd735..db3f749 100644
--- a/src/api/cocoa/mod.rs
+++ b/src/api/cocoa/mod.rs
@@ -42,10 +42,10 @@ use std::sync::Mutex;
use std::ascii::AsciiExt;
use std::ops::Deref;
-use events::Event::{Awakened, MouseInput, MouseMoved, ReceivedCharacter, KeyboardInput, MouseWheel, Closed, Focused, TouchpadPressure};
use events::ElementState::{Pressed, Released};
-use events::MouseButton;
-use events;
+use events::Event::{Awakened, MouseInput, MouseMoved, ReceivedCharacter, KeyboardInput};
+use events::Event::{MouseWheel, Closed, Focused, TouchpadPressure};
+use events::{self, MouseButton, TouchPhase};
pub use self::monitor::{MonitorId, get_available_monitors, get_primary_monitor};
pub use self::headless::HeadlessContext;
@@ -891,7 +891,12 @@ unsafe fn NSEventToEvent(window: &Window, nsevent: id) -> Option<Event> {
LineDelta(scale_factor * nsevent.scrollingDeltaX() as f32,
scale_factor * nsevent.scrollingDeltaY() as f32)
};
- Some(MouseWheel(delta))
+ let phase = match nsevent.phase() {
+ NSEventPhaseMayBegin | NSEventPhaseBegan => TouchPhase::Started,
+ NSEventPhaseEnded => TouchPhase::Ended,
+ _ => TouchPhase::Moved,
+ };
+ Some(MouseWheel(delta, phase))
},
NSEventTypePressure => {
Some(TouchpadPressure(nsevent.pressure(), nsevent.stage()))