diff options
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | src/api/cocoa/mod.rs | 17 | ||||
-rw-r--r-- | src/api/wayland/events.rs | 6 | ||||
-rw-r--r-- | src/api/win32/callback.rs | 3 | ||||
-rw-r--r-- | src/api/x11/input.rs | 5 | ||||
-rw-r--r-- | src/events.rs | 2 |
6 files changed, 23 insertions, 12 deletions
@@ -42,7 +42,7 @@ objc = "0.1.8" cgl = "0.1" cocoa = "0.2.4" core-foundation = "0" -core-graphics = "0" +core-graphics = "0.3" [target.i686-pc-windows-gnu.dependencies] winapi = "0.2" diff --git a/src/api/cocoa/mod.rs b/src/api/cocoa/mod.rs index ca77ce9..bec56d2 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; @@ -412,7 +412,9 @@ impl Window { let masks = if screen.is_some() || attrs.transparent { // Fullscreen or transparent window - NSBorderlessWindowMask as NSUInteger + NSBorderlessWindowMask as NSUInteger | + NSResizableWindowMask as NSUInteger | + NSTitledWindowMask as NSUInteger } else if attrs.decorations { // Classic opaque window with titlebar NSClosableWindowMask as NSUInteger | @@ -903,7 +905,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), |