aboutsummaryrefslogtreecommitdiffstats
path: root/src/api/win32/mod.rs
diff options
context:
space:
mode:
authorAceeri <conmcclusk@gmail.com>2015-11-09 02:49:50 -0800
committerAceeri <conmcclusk@gmail.com>2015-11-09 02:49:50 -0800
commitd6a53cf5d3ba9c41f4bd6255012ac2adfc6487b4 (patch)
tree1fa8ce90ad3e9754e3dd56e9493e878dfe675826 /src/api/win32/mod.rs
parent78eb4a5990dadb3402dd3e80d04e2cfd7f9dd6fd (diff)
downloadglutin-d6a53cf5d3ba9c41f4bd6255012ac2adfc6487b4.tar.gz
glutin-d6a53cf5d3ba9c41f4bd6255012ac2adfc6487b4.zip
Corrections to sharing data
Diffstat (limited to 'src/api/win32/mod.rs')
-rw-r--r--src/api/win32/mod.rs13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/api/win32/mod.rs b/src/api/win32/mod.rs
index 760020c..7a7f42a 100644
--- a/src/api/win32/mod.rs
+++ b/src/api/win32/mod.rs
@@ -42,6 +42,13 @@ lazy_static! {
static ref WAKEUP_MSG_ID: u32 = unsafe { user32::RegisterWindowMessageA("Glutin::EventID".as_ptr() as *const i8) };
}
+/// Contains information about states and the window for the callback.
+#[derive(Clone)]
+pub struct WindowState {
+ pub cursor_state: CursorState,
+ pub attributes: WindowAttributes
+}
+
/// The Win32 implementation of the main `Window` object.
pub struct Window {
/// Main handle for the window.
@@ -53,8 +60,8 @@ pub struct Window {
/// Receiver for the events dispatched by the window callback.
events_receiver: Receiver<Event>,
- /// The current cursor state.
- cursor_state: CursorState,
+ /// The current window state.
+ window_state: Arc<Mutex<WindowState>>,
}
unsafe impl Send for Window {}
@@ -258,7 +265,7 @@ impl Window {
}
pub fn set_cursor_state(&self, state: CursorState) -> Result<(), String> {
- let mut current_state = self.cursor_state;
+ let mut current_state = self.window_state.lock().unwrap().cursor_state;
let foreground_thread_id = unsafe { user32::GetWindowThreadProcessId(self.window.0, ptr::null_mut()) };
let current_thread_id = unsafe { kernel32::GetCurrentThreadId() };