aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Rouget <me@paulrouget.com>2016-03-04 01:28:43 +0100
committerPaul Rouget <me@paulrouget.com>2016-03-04 01:28:43 +0100
commite843206c1303475678482f623477408468b8a74b (patch)
tree1243ddf9e5b337b0b8ad91eabc269ce429072a4b /src
parent2638db665afc175cf128c3e25bc883f4c114bb5a (diff)
parent7886ff9acdbc4961359725536c1a15e2cbb3d4f5 (diff)
downloadglutin-e843206c1303475678482f623477408468b8a74b.tar.gz
glutin-e843206c1303475678482f623477408468b8a74b.zip
Merge pull request #735 from metajack/overscroll-tomaka
Add phases to wheel events.
Diffstat (limited to 'src')
-rw-r--r--src/api/cocoa/mod.rs13
-rw-r--r--src/api/wayland/events.rs6
-rw-r--r--src/api/win32/callback.rs3
-rw-r--r--src/api/x11/input.rs5
-rw-r--r--src/events.rs2
5 files changed, 19 insertions, 10 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()))
diff --git a/src/api/wayland/events.rs b/src/api/wayland/events.rs
index 8b18020..5e0c3fd 100644
--- a/src/api/wayland/events.rs
+++ b/src/api/wayland/events.rs
@@ -1,5 +1,6 @@
use std::collections::HashSet;
+use TouchPhase;
use Event as GlutinEvent;
use ElementState;
use MouseButton;
@@ -98,7 +99,8 @@ pub fn translate_event(
WlPointerAxis::HorizontalScroll => {
MouseScrollDelta::PixelDelta(0.0, amplitude as f32)
}
- }
+ },
+ TouchPhase::Moved
), surface))
} else {
None
@@ -107,4 +109,4 @@ pub fn translate_event(
},
_ => None
}
-} \ No newline at end of file
+}
diff --git a/src/api/win32/callback.rs b/src/api/win32/callback.rs
index 0215c9f..2d10699 100644
--- a/src/api/win32/callback.rs
+++ b/src/api/win32/callback.rs
@@ -134,12 +134,13 @@ pub unsafe extern "system" fn callback(window: winapi::HWND, msg: winapi::UINT,
winapi::WM_MOUSEWHEEL => {
use events::Event::MouseWheel;
use events::MouseScrollDelta::LineDelta;
+ use events::TouchPhase;
let value = (wparam >> 16) as i16;
let value = value as i32;
let value = value as f32 / winapi::WHEEL_DELTA as f32;
- send_event(window, MouseWheel(LineDelta(0.0, value)));
+ send_event(window, MouseWheel(LineDelta(0.0, value), TouchPhase::Moved));
0
},
diff --git a/src/api/x11/input.rs b/src/api/x11/input.rs
index 2ebc989..a05b22e 100644
--- a/src/api/x11/input.rs
+++ b/src/api/x11/input.rs
@@ -201,7 +201,7 @@ impl XInputEventHandler {
} else {
-1.0
};
- Some(MouseWheel(LineDelta(0.0, delta)))
+ Some(MouseWheel(LineDelta(0.0, delta), TouchPhase::Moved))
} else {
// emulated button event from a touch/smooth-scroll
// event. Ignore these events and handle scrolling
@@ -235,7 +235,8 @@ impl XInputEventHandler {
}
if scroll_delta.0.abs() > 0.0 || scroll_delta.1.abs() > 0.0 {
- Some(MouseWheel(LineDelta(scroll_delta.0 as f32, scroll_delta.1 as f32)))
+ Some(MouseWheel(LineDelta(scroll_delta.0 as f32, scroll_delta.1 as f32),
+ TouchPhase::Moved))
} else {
let new_cursor_pos = (event_data.event_x, event_data.event_y);
if new_cursor_pos != self.current_state.cursor_pos {
diff --git a/src/events.rs b/src/events.rs
index ecc1041..8049c16 100644
--- a/src/events.rs
+++ b/src/events.rs
@@ -31,7 +31,7 @@ pub enum Event {
MouseMoved((i32, i32)),
/// A mouse wheel movement or touchpad scroll occurred.
- MouseWheel(MouseScrollDelta),
+ MouseWheel(MouseScrollDelta, TouchPhase),
/// An event from the mouse has been received.
MouseInput(ElementState, MouseButton),