diff options
author | Pierre Krieger <pierre.krieger1708@gmail.com> | 2015-03-26 19:01:27 +0100 |
---|---|---|
committer | Pierre Krieger <pierre.krieger1708@gmail.com> | 2015-03-30 11:42:19 +0200 |
commit | bae1e42b8b27ad2e66fa50c227d4ead0eae80993 (patch) | |
tree | 1fa760f84d2990ef07c3de98560f3124ee7b8c63 | |
parent | bb418efcc7d5bf38dcb37251ebd1350abb05aba3 (diff) | |
download | glutin-bae1e42b8b27ad2e66fa50c227d4ead0eae80993.tar.gz glutin-bae1e42b8b27ad2e66fa50c227d4ead0eae80993.zip |
More work on win32 implementation
-rw-r--r-- | examples/grabbing.rs | 5 | ||||
-rw-r--r-- | src/win32/mod.rs | 13 |
2 files changed, 16 insertions, 2 deletions
diff --git a/examples/grabbing.rs b/examples/grabbing.rs index 07e3873..8088774 100644 --- a/examples/grabbing.rs +++ b/examples/grabbing.rs @@ -42,6 +42,11 @@ fn main() { .ok().expect("could not grab mouse cursor"); } }, + + a @ Event::MouseMoved(_) => { + println!("{:?}", a); + }, + _ => (), } diff --git a/src/win32/mod.rs b/src/win32/mod.rs index 113bea1..c0708b8 100644 --- a/src/win32/mod.rs +++ b/src/win32/mod.rs @@ -262,7 +262,12 @@ impl Window { pub fn set_cursor_state(&self, state: CursorState) -> Result<(), String> { let mut current_state = self.cursor_state.lock().unwrap(); - match (state, *current_state) { + let foreground_thread_id = unsafe { user32::GetWindowThreadProcessId(self.window.0, ptr::null_mut()) }; + let current_thread_id = unsafe { kernel32::GetCurrentThreadId() }; + + unsafe { user32::AttachThreadInput(foreground_thread_id, current_thread_id, 1) }; + + let res = match (state, *current_state) { (CursorState::Normal, CursorState::Normal) => Ok(()), (CursorState::Hide, CursorState::Hide) => Ok(()), (CursorState::Grab, CursorState::Grab) => Ok(()), @@ -310,7 +315,11 @@ impl Window { }, _ => unimplemented!(), - } + }; + + unsafe { user32::AttachThreadInput(foreground_thread_id, current_thread_id, 0) }; + + res } pub fn hidpi_factor(&self) -> f32 { |