diff options
author | tomaka <pierre.krieger1708@gmail.com> | 2015-04-01 19:41:26 +0200 |
---|---|---|
committer | tomaka <pierre.krieger1708@gmail.com> | 2015-04-01 19:41:26 +0200 |
commit | a0ac31b70f79c5a9f182971e3f3ac3fcd7b41b54 (patch) | |
tree | 2e5ffd8218297994d7de8dacb76d4749a312bc83 /src/win32/init.rs | |
parent | 837ea45867fc7acca15564d18244c200a50b5a67 (diff) | |
parent | e51dd82478c0f0eb3e8b54ce6439f6e0d7bb92dc (diff) | |
download | glutin-a0ac31b70f79c5a9f182971e3f3ac3fcd7b41b54.tar.gz glutin-a0ac31b70f79c5a9f182971e3f3ac3fcd7b41b54.zip |
Merge pull request #338 from XMPPwocky/master
Fix WM_SETCURSOR
Diffstat (limited to 'src/win32/init.rs')
-rw-r--r-- | src/win32/init.rs | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/win32/init.rs b/src/win32/init.rs index c5e18cc..08fb3b3 100644 --- a/src/win32/init.rs +++ b/src/win32/init.rs @@ -1,4 +1,8 @@ use std::sync::atomic::AtomicBool; +use std::sync::{ + Arc, + Mutex +}; use std::ptr; use std::mem; use std::os; @@ -21,7 +25,6 @@ use PixelFormat; use std::ffi::CString; use std::sync::mpsc::channel; -use std::sync::Mutex; use libc; use super::gl; @@ -221,12 +224,20 @@ unsafe fn init(title: Vec<u16>, builder: BuilderAttribs<'static>, user32::SetForegroundWindow(real_window.0); } - // filling the WINDOW task-local storage so that we can start receiving events + // Creating a mutex to track the current cursor state + let cursor_state = Arc::new(Mutex::new(CursorState::Normal)); + + // filling the CONTEXT_STASH task-local storage so that we can start receiving events let events_receiver = { let (tx, rx) = channel(); let mut tx = Some(tx); - callback::WINDOW.with(|window| { - (*window.borrow_mut()) = Some((real_window.0, tx.take().unwrap())); + callback::CONTEXT_STASH.with(|context_stash| { + let data = callback::ThreadLocalData { + win: real_window.0, + sender: tx.take().unwrap(), + cursor_state: cursor_state.clone() + }; + (*context_stash.borrow_mut()) = Some(data); }); rx }; @@ -252,7 +263,7 @@ unsafe fn init(title: Vec<u16>, builder: BuilderAttribs<'static>, gl_library: gl_library, events_receiver: events_receiver, is_closed: AtomicBool::new(false), - cursor_state: Mutex::new(CursorState::Normal), + cursor_state: cursor_state, }) } |