aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortomaka <pierre.krieger1708@gmail.com>2015-09-23 13:09:36 +0200
committertomaka <pierre.krieger1708@gmail.com>2015-09-23 13:09:36 +0200
commit3820d307a3f23828790e8a46a9c46849592104d6 (patch)
tree76bb26b4078ee344089c20f3288d047fc394d705
parent0f9693bde4d67e77fa3691a2c9d3ed0151abec71 (diff)
parent6ece84f5c04f7b290bdd02cf40032f6e8444ccf6 (diff)
downloadglutin-3820d307a3f23828790e8a46a9c46849592104d6.tar.gz
glutin-3820d307a3f23828790e8a46a9c46849592104d6.zip
Merge pull request #611 from vvuk/win32
fix up win32 support
-rw-r--r--.gitignore2
-rw-r--r--Cargo.toml8
-rw-r--r--src/api/win32/callback.rs6
-rw-r--r--src/api/win32/mod.rs19
4 files changed, 27 insertions, 8 deletions
diff --git a/.gitignore b/.gitignore
index 1e7caa9..a36df82 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,4 @@
Cargo.lock
target/
+*~
+#*#
diff --git a/Cargo.toml b/Cargo.toml
index e35bbaf..c649cde 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -56,7 +56,7 @@ core-graphics = "0"
winapi = "0.2"
shell32-sys = "0.1"
gdi32-sys = "0.1"
-user32-sys = "~0.1.1"
+user32-sys = "~0.1.2"
kernel32-sys = "0.1"
dwmapi-sys = "0.1"
@@ -64,7 +64,7 @@ dwmapi-sys = "0.1"
winapi = "0.2"
shell32-sys = "0.1"
gdi32-sys = "0.1"
-user32-sys = "~0.1.1"
+user32-sys = "~0.1.2"
kernel32-sys = "0.1"
dwmapi-sys = "0.1"
@@ -72,7 +72,7 @@ dwmapi-sys = "0.1"
winapi = "0.2"
shell32-sys = "0.1"
gdi32-sys = "0.1"
-user32-sys = "~0.1.1"
+user32-sys = "~0.1.2"
kernel32-sys = "0.1"
dwmapi-sys = "0.1"
@@ -80,7 +80,7 @@ dwmapi-sys = "0.1"
winapi = "0.2"
shell32-sys = "0.1"
gdi32-sys = "0.1"
-user32-sys = "~0.1.1"
+user32-sys = "~0.1.2"
kernel32-sys = "0.1"
dwmapi-sys = "0.1"
diff --git a/src/api/win32/callback.rs b/src/api/win32/callback.rs
index da8e1a6..45de907 100644
--- a/src/api/win32/callback.rs
+++ b/src/api/win32/callback.rs
@@ -281,6 +281,12 @@ pub unsafe extern "system" fn callback(window: winapi::HWND, msg: winapi::UINT,
0
},
+ x if x == *super::WAKEUP_MSG_ID => {
+ use events::Event::Awakened;
+ send_event(window, Awakened);
+ 0
+ },
+
_ => {
user32::DefWindowProcW(window, msg, wparam, lparam)
}
diff --git a/src/api/win32/mod.rs b/src/api/win32/mod.rs
index f580950..235fa2f 100644
--- a/src/api/win32/mod.rs
+++ b/src/api/win32/mod.rs
@@ -38,6 +38,10 @@ mod event;
mod init;
mod monitor;
+lazy_static! {
+ static ref WAKEUP_MSG_ID: u32 = unsafe { user32::RegisterWindowMessageA("Glutin::EventID".as_ptr() as *const i8) };
+}
+
/// The Win32 implementation of the main `Window` object.
pub struct Window {
/// Main handle for the window.
@@ -75,11 +79,15 @@ impl Drop for WindowWrapper {
}
#[derive(Clone)]
-pub struct WindowProxy;
+pub struct WindowProxy {
+ hwnd: winapi::HWND,
+}
impl WindowProxy {
pub fn wakeup_event_loop(&self) {
- unimplemented!()
+ unsafe {
+ user32::PostMessageA(self.hwnd, *WAKEUP_MSG_ID, 0, 0);
+ }
}
}
@@ -189,7 +197,7 @@ impl Window {
}
pub fn create_window_proxy(&self) -> WindowProxy {
- WindowProxy
+ WindowProxy { hwnd: self.window.0 }
}
/// See the docs in the crate root file.
@@ -207,7 +215,10 @@ impl Window {
}
pub fn platform_display(&self) -> *mut libc::c_void {
- unimplemented!()
+ // What should this return on win32?
+ // It could be GetDC(NULL), but that requires a ReleaseDC()
+ // to avoid leaking the DC.
+ ptr::null_mut()
}
pub fn platform_window(&self) -> *mut libc::c_void {