aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Cargo.toml8
-rw-r--r--src/lib.rs2
-rw-r--r--src/win32/event.rs278
-rw-r--r--src/win32/ffi.rs770
-rw-r--r--src/win32/gl.rs26
-rw-r--r--src/win32/init.rs253
-rw-r--r--src/win32/mod.rs62
-rw-r--r--src/win32/monitor.rs30
8 files changed, 351 insertions, 1078 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 43e594b..fc2be6f 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -37,3 +37,11 @@ git = "https://github.com/servo/rust-core-graphics"
[target.x86_64-apple-darwin.dependencies.core_graphics]
git = "https://github.com/servo/rust-core-graphics"
+
+[target.i686-pc-windows-gnu.dependencies.winapi]
+git = "https://github.com/retep998/winapi-rs"
+features = ["gdi32", "kernel32", "user32"]
+
+[target.x86_64-pc-windows-gnu.dependencies.winapi]
+git = "https://github.com/retep998/winapi-rs"
+features = ["gdi32", "kernel32", "user32"]
diff --git a/src/lib.rs b/src/lib.rs
index 0e61649..53b540b 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -36,6 +36,8 @@
extern crate gl_common;
extern crate libc;
+#[cfg(target_os = "windows")]
+extern crate winapi;
#[cfg(target_os = "macos")]
extern crate cocoa;
#[cfg(target_os = "macos")]
diff --git a/src/win32/event.rs b/src/win32/event.rs
index a77f40c..16080eb 100644
--- a/src/win32/event.rs
+++ b/src/win32/event.rs
@@ -1,51 +1,51 @@
use events;
-use super::ffi;
+use winapi;
-pub fn vkeycode_to_element(code: ffi::WPARAM) -> Option<events::VirtualKeyCode> {
+pub fn vkeycode_to_element(code: winapi::WPARAM) -> Option<events::VirtualKeyCode> {
Some(match code {
- //ffi::VK_LBUTTON => events::VirtualKeyCode::Lbutton,
- //ffi::VK_RBUTTON => events::VirtualKeyCode::Rbutton,
- //ffi::VK_CANCEL => events::VirtualKeyCode::Cancel,
- //ffi::VK_MBUTTON => events::VirtualKeyCode::Mbutton,
- //ffi::VK_XBUTTON1 => events::VirtualKeyCode::Xbutton1,
- //ffi::VK_XBUTTON2 => events::VirtualKeyCode::Xbutton2,
- ffi::VK_BACK => events::VirtualKeyCode::Back,
- ffi::VK_TAB => events::VirtualKeyCode::Tab,
- //ffi::VK_CLEAR => events::VirtualKeyCode::Clear,
- ffi::VK_RETURN => events::VirtualKeyCode::Return,
- //ffi::VK_SHIFT => events::VirtualKeyCode::Shift,
- //ffi::VK_CONTROL => events::VirtualKeyCode::Control,
- //ffi::VK_MENU => events::VirtualKeyCode::Menu,
- ffi::VK_PAUSE => events::VirtualKeyCode::Pause,
- ffi::VK_CAPITAL => events::VirtualKeyCode::Capital,
- ffi::VK_KANA => events::VirtualKeyCode::Kana,
- //ffi::VK_HANGUEL => events::VirtualKeyCode::Hanguel,
- //ffi::VK_HANGUL => events::VirtualKeyCode::Hangul,
- //ffi::VK_JUNJA => events::VirtualKeyCode::Junja,
- //ffi::VK_FINAL => events::VirtualKeyCode::Final,
- //ffi::VK_HANJA => events::VirtualKeyCode::Hanja,
- ffi::VK_KANJI => events::VirtualKeyCode::Kanji,
- ffi::VK_ESCAPE => events::VirtualKeyCode::Escape,
- ffi::VK_CONVERT => events::VirtualKeyCode::Convert,
- //ffi::VK_NONCONVERT => events::VirtualKeyCode::Nonconvert,
- //ffi::VK_ACCEPT => events::VirtualKeyCode::Accept,
- //ffi::VK_MODECHANGE => events::VirtualKeyCode::Modechange,
- ffi::VK_SPACE => events::VirtualKeyCode::Space,
- ffi::VK_PRIOR => events::VirtualKeyCode::PageUp,
- ffi::VK_NEXT => events::VirtualKeyCode::PageDown,
- ffi::VK_END => events::VirtualKeyCode::End,
- ffi::VK_HOME => events::VirtualKeyCode::Home,
- ffi::VK_LEFT => events::VirtualKeyCode::Left,
- ffi::VK_UP => events::VirtualKeyCode::Up,
- ffi::VK_RIGHT => events::VirtualKeyCode::Right,
- ffi::VK_DOWN => events::VirtualKeyCode::Down,
- //ffi::VK_SELECT => events::VirtualKeyCode::Select,
- //ffi::VK_PRINT => events::VirtualKeyCode::Print,
- //ffi::VK_EXECUTE => events::VirtualKeyCode::Execute,
- ffi::VK_SNAPSHOT => events::VirtualKeyCode::Snapshot,
- ffi::VK_INSERT => events::VirtualKeyCode::Insert,
- ffi::VK_DELETE => events::VirtualKeyCode::Delete,
- //ffi::VK_HELP => events::VirtualKeyCode::Help,
+ //winapi::VK_LBUTTON => events::VirtualKeyCode::Lbutton,
+ //winapi::VK_RBUTTON => events::VirtualKeyCode::Rbutton,
+ //winapi::VK_CANCEL => events::VirtualKeyCode::Cancel,
+ //winapi::VK_MBUTTON => events::VirtualKeyCode::Mbutton,
+ //winapi::VK_XBUTTON1 => events::VirtualKeyCode::Xbutton1,
+ //winapi::VK_XBUTTON2 => events::VirtualKeyCode::Xbutton2,
+ winapi::VK_BACK => events::VirtualKeyCode::Back,
+ winapi::VK_TAB => events::VirtualKeyCode::Tab,
+ //winapi::VK_CLEAR => events::VirtualKeyCode::Clear,
+ winapi::VK_RETURN => events::VirtualKeyCode::Return,
+ //winapi::VK_SHIFT => events::VirtualKeyCode::Shift,
+ //winapi::VK_CONTROL => events::VirtualKeyCode::Control,
+ //winapi::VK_MENU => events::VirtualKeyCode::Menu,
+ winapi::VK_PAUSE => events::VirtualKeyCode::Pause,
+ winapi::VK_CAPITAL => events::VirtualKeyCode::Capital,
+ winapi::VK_KANA => events::VirtualKeyCode::Kana,
+ //winapi::VK_HANGUEL => events::VirtualKeyCode::Hanguel,
+ //winapi::VK_HANGUL => events::VirtualKeyCode::Hangul,
+ //winapi::VK_JUNJA => events::VirtualKeyCode::Junja,
+ //winapi::VK_FINAL => events::VirtualKeyCode::Final,
+ //winapi::VK_HANJA => events::VirtualKeyCode::Hanja,
+ winapi::VK_KANJI => events::VirtualKeyCode::Kanji,
+ winapi::VK_ESCAPE => events::VirtualKeyCode::Escape,
+ winapi::VK_CONVERT => events::VirtualKeyCode::Convert,
+ //winapi::VK_NONCONVERT => events::VirtualKeyCode::Nonconvert,
+ //winapi::VK_ACCEPT => events::VirtualKeyCode::Accept,
+ //winapi::VK_MODECHANGE => events::VirtualKeyCode::Modechange,
+ winapi::VK_SPACE => events::VirtualKeyCode::Space,
+ winapi::VK_PRIOR => events::VirtualKeyCode::PageUp,
+ winapi::VK_NEXT => events::VirtualKeyCode::PageDown,
+ winapi::VK_END => events::VirtualKeyCode::End,
+ winapi::VK_HOME => events::VirtualKeyCode::Home,
+ winapi::VK_LEFT => events::VirtualKeyCode::Left,
+ winapi::VK_UP => events::VirtualKeyCode::Up,
+ winapi::VK_RIGHT => events::VirtualKeyCode::Right,
+ winapi::VK_DOWN => events::VirtualKeyCode::Down,
+ //winapi::VK_SELECT => events::VirtualKeyCode::Select,
+ //winapi::VK_PRINT => events::VirtualKeyCode::Print,
+ //winapi::VK_EXECUTE => events::VirtualKeyCode::Execute,
+ winapi::VK_SNAPSHOT => events::VirtualKeyCode::Snapshot,
+ winapi::VK_INSERT => events::VirtualKeyCode::Insert,
+ winapi::VK_DELETE => events::VirtualKeyCode::Delete,
+ //winapi::VK_HELP => events::VirtualKeyCode::Help,
0x30 => events::VirtualKeyCode::Key0,
0x31 => events::VirtualKeyCode::Key1,
0x32 => events::VirtualKeyCode::Key2,
@@ -82,100 +82,100 @@ pub fn vkeycode_to_element(code: ffi::WPARAM) -> Option<events::VirtualKeyCode>
0x58 => events::VirtualKeyCode::X,
0x59 => events::VirtualKeyCode::Y,
0x5A => events::VirtualKeyCode::Z,
- //ffi::VK_LWIN => events::VirtualKeyCode::Lwin,
- //ffi::VK_RWIN => events::VirtualKeyCode::Rwin,
- ffi::VK_APPS => events::VirtualKeyCode::Apps,
- ffi::VK_SLEEP => events::VirtualKeyCode::Sleep,
- ffi::VK_NUMPAD0 => events::VirtualKeyCode::Numpad0,
- ffi::VK_NUMPAD1 => events::VirtualKeyCode::Numpad1,
- ffi::VK_NUMPAD2 => events::VirtualKeyCode::Numpad2,
- ffi::VK_NUMPAD3 => events::VirtualKeyCode::Numpad3,
- ffi::VK_NUMPAD4 => events::VirtualKeyCode::Numpad4,
- ffi::VK_NUMPAD5 => events::VirtualKeyCode::Numpad5,
- ffi::VK_NUMPAD6 => events::VirtualKeyCode::Numpad6,
- ffi::VK_NUMPAD7 => events::VirtualKeyCode::Numpad7,
- ffi::VK_NUMPAD8 => events::VirtualKeyCode::Numpad8,
- ffi::VK_NUMPAD9 => events::VirtualKeyCode::Numpad9,
- ffi::VK_MULTIPLY => events::VirtualKeyCode::Multiply,
- ffi::VK_ADD => events::VirtualKeyCode::Add,
- //ffi::VK_SEPARATOR => events::VirtualKeyCode::Separator,
- ffi::VK_SUBTRACT => events::VirtualKeyCode::Subtract,
- ffi::VK_DECIMAL => events::VirtualKeyCode::Decimal,
- ffi::VK_DIVIDE => events::VirtualKeyCode::Divide,
- ffi::VK_F1 => events::VirtualKeyCode::F1,
- ffi::VK_F2 => events::VirtualKeyCode::F2,
- ffi::VK_F3 => events::VirtualKeyCode::F3,
- ffi::VK_F4 => events::VirtualKeyCode::F4,
- ffi::VK_F5 => events::VirtualKeyCode::F5,
- ffi::VK_F6 => events::VirtualKeyCode::F6,
- ffi::VK_F7 => events::VirtualKeyCode::F7,
- ffi::VK_F8 => events::VirtualKeyCode::F8,
- ffi::VK_F9 => events::VirtualKeyCode::F9,
- ffi::VK_F10 => events::VirtualKeyCode::F10,
- ffi::VK_F11 => events::VirtualKeyCode::F11,
- ffi::VK_F12 => events::VirtualKeyCode::F12,
- ffi::VK_F13 => events::VirtualKeyCode::F13,
- ffi::VK_F14 => events::VirtualKeyCode::F14,
- ffi::VK_F15 => events::VirtualKeyCode::F15,
- /*ffi::VK_F16 => events::VirtualKeyCode::F16,
- ffi::VK_F17 => events::VirtualKeyCode::F17,
- ffi::VK_F18 => events::VirtualKeyCode::F18,
- ffi::VK_F19 => events::VirtualKeyCode::F19,
- ffi::VK_F20 => events::VirtualKeyCode::F20,
- ffi::VK_F21 => events::VirtualKeyCode::F21,
- ffi::VK_F22 => events::VirtualKeyCode::F22,
- ffi::VK_F23 => events::VirtualKeyCode::F23,
- ffi::VK_F24 => events::VirtualKeyCode::F24,*/
- ffi::VK_NUMLOCK => events::VirtualKeyCode::Numlock,
- ffi::VK_SCROLL => events::VirtualKeyCode::Scroll,
- /*ffi::VK_LSHIFT => events::VirtualKeyCode::Lshift,
- ffi::VK_RSHIFT => events::VirtualKeyCode::Rshift,
- ffi::VK_LCONTROL => events::VirtualKeyCode::Lcontrol,
- ffi::VK_RCONTROL => events::VirtualKeyCode::Rcontrol,
- ffi::VK_LMENU => events::VirtualKeyCode::Lmenu,
- ffi::VK_RMENU => events::VirtualKeyCode::Rmenu,
- ffi::VK_BROWSER_BACK => events::VirtualKeyCode::Browser_back,
- ffi::VK_BROWSER_FORWARD => events::VirtualKeyCode::Browser_forward,
- ffi::VK_BROWSER_REFRESH => events::VirtualKeyCode::Browser_refresh,
- ffi::VK_BROWSER_STOP => events::VirtualKeyCode::Browser_stop,
- ffi::VK_BROWSER_SEARCH => events::VirtualKeyCode::Browser_search,
- ffi::VK_BROWSER_FAVORITES => events::VirtualKeyCode::Browser_favorites,
- ffi::VK_BROWSER_HOME => events::VirtualKeyCode::Browser_home,
- ffi::VK_VOLUME_MUTE => events::VirtualKeyCode::Volume_mute,
- ffi::VK_VOLUME_DOWN => events::VirtualKeyCode::Volume_down,
- ffi::VK_VOLUME_UP => events::VirtualKeyCode::Volume_up,
- ffi::VK_MEDIA_NEXT_TRACK => events::VirtualKeyCode::Media_next_track,
- ffi::VK_MEDIA_PREV_TRACK => events::VirtualKeyCode::Media_prev_track,
- ffi::VK_MEDIA_STOP => events::VirtualKeyCode::Media_stop,
- ffi::VK_MEDIA_PLAY_PAUSE => events::VirtualKeyCode::Media_play_pause,
- ffi::VK_LAUNCH_MAIL => events::VirtualKeyCode::Launch_mail,
- ffi::VK_LAUNCH_MEDIA_SELECT => events::VirtualKeyCode::Launch_media_select,
- ffi::VK_LAUNCH_APP1 => events::VirtualKeyCode::Launch_app1,
- ffi::VK_LAUNCH_APP2 => events::VirtualKeyCode::Launch_app2,
- ffi::VK_OEM_1 => events::VirtualKeyCode::Oem_1,
- ffi::VK_OEM_PLUS => events::VirtualKeyCode::Oem_plus,
- ffi::VK_OEM_COMMA => events::VirtualKeyCode::Oem_comma,
- ffi::VK_OEM_MINUS => events::VirtualKeyCode::Oem_minus,
- ffi::VK_OEM_PERIOD => events::VirtualKeyCode::Oem_period,
- ffi::VK_OEM_2 => events::VirtualKeyCode::Oem_2,
- ffi::VK_OEM_3 => events::VirtualKeyCode::Oem_3,
- ffi::VK_OEM_4 => events::VirtualKeyCode::Oem_4,
- ffi::VK_OEM_5 => events::VirtualKeyCode::Oem_5,
- ffi::VK_OEM_6 => events::VirtualKeyCode::Oem_6,
- ffi::VK_OEM_7 => events::VirtualKeyCode::Oem_7,
- ffi::VK_OEM_8 => events::VirtualKeyCode::Oem_8,
- ffi::VK_OEM_102 => events::VirtualKeyCode::Oem_102,
- ffi::VK_PROCESSKEY => events::VirtualKeyCode::Processkey,
- ffi::VK_PACKET => events::VirtualKeyCode::Packet,
- ffi::VK_ATTN => events::VirtualKeyCode::Attn,
- ffi::VK_CRSEL => events::VirtualKeyCode::Crsel,
- ffi::VK_EXSEL => events::VirtualKeyCode::Exsel,
- ffi::VK_EREOF => events::VirtualKeyCode::Ereof,
- ffi::VK_PLAY => events::VirtualKeyCode::Play,
- ffi::VK_ZOOM => events::VirtualKeyCode::Zoom,
- ffi::VK_NONAME => events::VirtualKeyCode::Noname,
- ffi::VK_PA1 => events::VirtualKeyCode::Pa1,
- ffi::VK_OEM_CLEAR => events::VirtualKeyCode::Oem_clear,*/
+ //winapi::VK_LWIN => events::VirtualKeyCode::Lwin,
+ //winapi::VK_RWIN => events::VirtualKeyCode::Rwin,
+ winapi::VK_APPS => events::VirtualKeyCode::Apps,
+ winapi::VK_SLEEP => events::VirtualKeyCode::Sleep,
+ winapi::VK_NUMPAD0 => events::VirtualKeyCode::Numpad0,
+ winapi::VK_NUMPAD1 => events::VirtualKeyCode::Numpad1,
+ winapi::VK_NUMPAD2 => events::VirtualKeyCode::Numpad2,
+ winapi::VK_NUMPAD3 => events::VirtualKeyCode::Numpad3,
+ winapi::VK_NUMPAD4 => events::VirtualKeyCode::Numpad4,
+ winapi::VK_NUMPAD5 => events::VirtualKeyCode::Numpad5,
+ winapi::VK_NUMPAD6 => events::VirtualKeyCode::Numpad6,
+ winapi::VK_NUMPAD7 => events::VirtualKeyCode::Numpad7,
+ winapi::VK_NUMPAD8 => events::VirtualKeyCode::Numpad8,
+ winapi::VK_NUMPAD9 => events::VirtualKeyCode::Numpad9,
+ winapi::VK_MULTIPLY => events::VirtualKeyCode::Multiply,
+ winapi::VK_ADD => events::VirtualKeyCode::Add,
+ //winapi::VK_SEPARATOR => events::VirtualKeyCode::Separator,
+ winapi::VK_SUBTRACT => events::VirtualKeyCode::Subtract,
+ winapi::VK_DECIMAL => events::VirtualKeyCode::Decimal,
+ winapi::VK_DIVIDE => events::VirtualKeyCode::Divide,
+ winapi::VK_F1 => events::VirtualKeyCode::F1,
+ winapi::VK_F2 => events::VirtualKeyCode::F2,
+ winapi::VK_F3 => events::VirtualKeyCode::F3,
+ winapi::VK_F4 => events::VirtualKeyCode::F4,
+ winapi::VK_F5 => events::VirtualKeyCode::F5,
+ winapi::VK_F6 => events::VirtualKeyCode::F6,
+ winapi::VK_F7 => events::VirtualKeyCode::F7,
+ winapi::VK_F8 => events::VirtualKeyCode::F8,
+ winapi::VK_F9 => events::VirtualKeyCode::F9,
+ winapi::VK_F10 => events::VirtualKeyCode::F10,
+ winapi::VK_F11 => events::VirtualKeyCode::F11,
+ winapi::VK_F12 => events::VirtualKeyCode::F12,
+ winapi::VK_F13 => events::VirtualKeyCode::F13,
+ winapi::VK_F14 => events::VirtualKeyCode::F14,
+ winapi::VK_F15 => events::VirtualKeyCode::F15,
+ /*winapi::VK_F16 => events::VirtualKeyCode::F16,
+ winapi::VK_F17 => events::VirtualKeyCode::F17,
+ winapi::VK_F18 => events::VirtualKeyCode::F18,
+ winapi::VK_F19 => events::VirtualKeyCode::F19,
+ winapi::VK_F20 => events::VirtualKeyCode::F20,
+ winapi::VK_F21 => events::VirtualKeyCode::F21,
+ winapi::VK_F22 => events::VirtualKeyCode::F22,
+ winapi::VK_F23 => events::VirtualKeyCode::F23,
+ winapi::VK_F24 => events::VirtualKeyCode::F24,*/
+ winapi::VK_NUMLOCK => events::VirtualKeyCode::Numlock,
+ winapi::VK_SCROLL => events::VirtualKeyCode::Scroll,
+ /*winapi::VK_LSHIFT => events::VirtualKeyCode::Lshift,
+ winapi::VK_RSHIFT => events::VirtualKeyCode::Rshift,
+ winapi::VK_LCONTROL => events::VirtualKeyCode::Lcontrol,
+ winapi::VK_RCONTROL => events::VirtualKeyCode::Rcontrol,
+ winapi::VK_LMENU => events::VirtualKeyCode::Lmenu,
+ winapi::VK_RMENU => events::VirtualKeyCode::Rmenu,
+ winapi::VK_BROWSER_BACK => events::VirtualKeyCode::Browser_back,
+ winapi::VK_BROWSER_FORWARD => events::VirtualKeyCode::Browser_forward,
+ winapi::VK_BROWSER_REFRESH => events::VirtualKeyCode::Browser_refresh,
+ winapi::VK_BROWSER_STOP => events::VirtualKeyCode::Browser_stop,
+ winapi::VK_BROWSER_SEARCH => events::VirtualKeyCode::Browser_search,
+ winapi::VK_BROWSER_FAVORITES => events::VirtualKeyCode::Browser_favorites,
+ winapi::VK_BROWSER_HOME => events::VirtualKeyCode::Browser_home,
+ winapi::VK_VOLUME_MUTE => events::VirtualKeyCode::Volume_mute,
+ winapi::VK_VOLUME_DOWN => events::VirtualKeyCode::Volume_down,
+ winapi::VK_VOLUME_UP => events::VirtualKeyCode::Volume_up,
+ winapi::VK_MEDIA_NEXT_TRACK => events::VirtualKeyCode::Media_next_track,
+ winapi::VK_MEDIA_PREV_TRACK => events::VirtualKeyCode::Media_prev_track,
+ winapi::VK_MEDIA_STOP => events::VirtualKeyCode::Media_stop,
+ winapi::VK_MEDIA_PLAY_PAUSE => events::VirtualKeyCode::Media_play_pause,
+ winapi::VK_LAUNCH_MAIL => events::VirtualKeyCode::Launch_mail,
+ winapi::VK_LAUNCH_MEDIA_SELECT => events::VirtualKeyCode::Launch_media_select,
+ winapi::VK_LAUNCH_APP1 => events::VirtualKeyCode::Launch_app1,
+ winapi::VK_LAUNCH_APP2 => events::VirtualKeyCode::Launch_app2,
+ winapi::VK_OEM_1 => events::VirtualKeyCode::Oem_1,
+ winapi::VK_OEM_PLUS => events::VirtualKeyCode::Oem_plus,
+ winapi::VK_OEM_COMMA => events::VirtualKeyCode::Oem_comma,
+ winapi::VK_OEM_MINUS => events::VirtualKeyCode::Oem_minus,
+ winapi::VK_OEM_PERIOD => events::VirtualKeyCode::Oem_period,
+ winapi::VK_OEM_2 => events::VirtualKeyCode::Oem_2,
+ winapi::VK_OEM_3 => events::VirtualKeyCode::Oem_3,
+ winapi::VK_OEM_4 => events::VirtualKeyCode::Oem_4,
+ winapi::VK_OEM_5 => events::VirtualKeyCode::Oem_5,
+ winapi::VK_OEM_6 => events::VirtualKeyCode::Oem_6,
+ winapi::VK_OEM_7 => events::VirtualKeyCode::Oem_7,
+ winapi::VK_OEM_8 => events::VirtualKeyCode::Oem_8,
+ winapi::VK_OEM_102 => events::VirtualKeyCode::Oem_102,
+ winapi::VK_PROCESSKEY => events::VirtualKeyCode::Processkey,
+ winapi::VK_PACKET => events::VirtualKeyCode::Packet,
+ winapi::VK_ATTN => events::VirtualKeyCode::Attn,
+ winapi::VK_CRSEL => events::VirtualKeyCode::Crsel,
+ winapi::VK_EXSEL => events::VirtualKeyCode::Exsel,
+ winapi::VK_EREOF => events::VirtualKeyCode::Ereof,
+ winapi::VK_PLAY => events::VirtualKeyCode::Play,
+ winapi::VK_ZOOM => events::VirtualKeyCode::Zoom,
+ winapi::VK_NONAME => events::VirtualKeyCode::Noname,
+ winapi::VK_PA1 => events::VirtualKeyCode::Pa1,
+ winapi::VK_OEM_CLEAR => events::VirtualKeyCode::Oem_clear,*/
_ => return None
})
}
diff --git a/src/win32/ffi.rs b/src/win32/ffi.rs
deleted file mode 100644
index 1920970..0000000
--- a/src/win32/ffi.rs
+++ /dev/null
@@ -1,770 +0,0 @@
-#![allow(dead_code)]
-#![allow(non_snake_case)]
-#![allow(non_camel_case_types)]
-#![allow(non_upper_case_globals)]
-
-use libc;
-
-/// WGL bindings
-pub mod wgl {
- generate_gl_bindings! {
- api: "wgl",
- profile: "core",
- version: "1.0",
- generator: "static"
- }
-}
-
-/// Functions that are not necessarly always available
-pub mod wgl_extra {
- generate_gl_bindings! {
- api: "wgl",
- profile: "core",
- version: "1.0",
- generator: "struct",
- extensions: [
- "WGL_ARB_create_context",
- "WGL_EXT_swap_control"
- ]
- }
-}
-
-// http://msdn.microsoft.com/en-us/library/windows/desktop/aa383751(v=vs.85).aspx
-// we don't define the T types to ensure that A/W functions are used
-pub type ATOM = WORD;
-pub type BOOL = libc::c_int;
-pub type BOOLEAN = BYTE;
-pub type BYTE = libc::c_uchar;
-pub type DWORD = libc::c_ulong;
-pub type HANDLE = PVOID;
-pub type HBRUSH = HANDLE;
-pub type HCURSOR = HICON;
-pub type HDC = HANDLE;
-pub type HICON = HANDLE;
-pub type HINSTANCE = HANDLE;
-pub type HLOCAL = HANDLE;
-pub type HMENU = HANDLE;
-pub type HMODULE = HINSTANCE;
-pub type HWND = HANDLE;
-pub type LONG = libc::c_long;
-pub type LONG_PTR = libc::intptr_t;
-pub type LPARAM = LONG_PTR;
-pub type LPCSTR = *const libc::c_char;
-pub type LPCWSTR = *const WCHAR;
-pub type LPCVOID = *const libc::c_void;
-pub type LPSTR = *mut libc::c_char;
-pub type LPVOID = *mut libc::c_void;
-pub type LPWSTR = *mut WCHAR;
-pub type LRESULT = LONG_PTR;
-pub type PVOID = *const libc::c_void;
-pub type UINT = libc::c_uint;
-pub type UINT_PTR = libc::intptr_t;
-pub type WCHAR = libc::wchar_t;
-pub type WORD = libc::c_ushort;
-pub type WPARAM = UINT_PTR;
-
-// macros
-pub fn LOWORD(l: DWORD) -> WORD {
- (l & 0xFFFF) as WORD
-}
-
-pub fn HIWORD(l: DWORD) -> WORD {
- (l >> 16) as WORD
-}
-
-pub fn GET_X_LPARAM(lp: LONG_PTR) -> libc::c_int {
- LOWORD(lp as DWORD) as libc::c_int
-}
-
-pub fn GET_Y_LPARAM(lp: LONG_PTR) -> libc::c_int {
- HIWORD(lp as DWORD) as libc::c_int
-}
-
-// http://msdn.microsoft.com/en-us/library/windows/desktop/ff485887(v=vs.85).aspx
-pub const BN_CLICKED: WORD = 0;
-pub const BN_DBLCLK: WORD = 5;
-pub const BN_DISABLE: WORD = 4;
-pub const BN_DOUBLECLICKED: WORD = 5;
-pub const BN_HILITE: WORD = 2;
-pub const BN_KILLFOCUS: WORD = 7;
-pub const BN_PAINT: WORD = 1;
-pub const BN_PUSHED: WORD = 2;
-pub const BN_SETFOCUS: WORD = 6;
-pub const BN_UNHILITE: WORD = 3;
-pub const BN_UNPUSHED: WORD = 3;
-
-// ?
-pub const BS_3STATE: DWORD = 5;
-pub const BS_AUTO3STATE: DWORD = 6;
-pub const BS_AUTOCHECKBOX: DWORD = 3;
-pub const BS_AUTORADIOBUTTON: DWORD = 9;
-pub const BS_BITMAP: DWORD = 128;
-pub const BS_BOTTOM: DWORD = 0x800;
-pub const BS_CENTER: DWORD = 0x300;
-pub const BS_CHECKBOX: DWORD = 2;
-pub const BS_DEFPUSHBUTTON: DWORD = 1;
-pub const BS_GROUPBOX: DWORD = 7;
-pub const BS_ICON: DWORD = 64;
-pub const BS_LEFT: DWORD = 256;
-pub const BS_LEFTTEXT: DWORD = 32;
-pub const BS_MULTILINE: DWORD = 0x2000;
-pub const BS_NOTIFY: DWORD = 0x4000;
-pub const BS_OWNERDRAW: DWORD = 0xb;
-pub const BS_PUSHBUTTON: DWORD = 0;
-pub const BS_PUSHLIKE: DWORD = 4096;
-pub const BS_RADIOBUTTON: DWORD = 4;
-pub const BS_RIGHT: DWORD = 512;
-pub const BS_RIGHTBUTTON: DWORD = 32;
-pub const BS_TEXT: DWORD = 0;
-pub const BS_TOP: DWORD = 0x400;
-pub const BS_USERBUTTON: DWORD = 8;
-pub const BS_VCENTER: DWORD = 0xc00;
-pub const BS_FLAT: DWORD = 0x8000;
-
-// ?
-pub const CDS_UPDATEREGISTRY: DWORD = 0x1;
-pub const CDS_TEST: DWORD = 0x2;
-pub const CDS_FULLSCREEN: DWORD = 0x4;
-pub const CDS_GLOBAL: DWORD = 0x8;
-pub const CDS_SET_PRIMARY: DWORD = 0x10;
-pub const CDS_VIDEOPARAMETERS: DWORD = 0x20;
-pub const CDS_NORESET: DWORD = 0x10000000;
-pub const CDS_SETRECT: DWORD = 0x20000000;
-pub const CDS_RESET: DWORD = 0x40000000;
-
-// http://msdn.microsoft.com/en-us/library/windows/desktop/ff729176(v=vs.85).aspx
-pub const CS_BYTEALIGNCLIENT: DWORD = 0x1000;
-pub const CS_BYTEALIGNWINDOW: DWORD = 0x2000;
-pub const CS_CLASSDC: DWORD = 0x0040;
-pub const CS_DBLCLKS: DWORD = 0x0008;
-pub const CS_DROPSHADOW: DWORD = 0x00020000;
-pub const CS_GLOBALCLASS: DWORD = 0x4000;
-pub const CS_HREDRAW: DWORD = 0x0002;
-pub const CS_NOCLOSE: DWORD = 0x0200;
-pub const CS_OWNDC: DWORD = 0x0020;
-pub const CS_PARENTDC: DWORD = 0x0080;
-pub const CS_SAVEBITS: DWORD = 0x0800;
-pub const CS_VREDRAW: DWORD = 0x0001;
-
-// ?
-#[allow(overflowing_literals)]
-pub const CW_USEDEFAULT: libc::c_int = 0x80000000;
-
-// ?
-pub const DISP_CHANGE_SUCCESSFUL: LONG = 0;
-pub const DISP_CHANGE_RESTART: LONG = 1;
-pub const DISP_CHANGE_FAILED: LONG = -1;
-pub const DISP_CHANGE_BADMODE: LONG = -2;
-pub const DISP_CHANGE_NOTUPDATED: LONG = -3;
-pub const DISP_CHANGE_BADFLAGS: LONG = -4;
-pub const DISP_CHANGE_BADPARAM: LONG = -5;
-pub const DISP_CHANGE_BADDUALVIEW: LONG = -6;
-
-// ?
-pub const DISPLAY_DEVICE_ACTIVE: DWORD = 0x00000001;
-pub const DISPLAY_DEVICE_MULTI_DRIVER: DWORD = 0x00000002;
-pub const DISPLAY_DEVICE_PRIMARY_DEVICE: DWORD = 0x00000004;
-pub const DISPLAY_DEVICE_MIRRORING_DRIVER: DWORD = 0x00000008;
-pub const DISPLAY_DEVICE_VGA_COMPATIBLE: DWORD = 0x00000010;
-
-// ?
-pub const DM_ORIENTATION: DWORD = 0x00000001;
-pub const DM_PAPERSIZE: DWORD = 0x00000002;
-pub const DM_PAPERLENGTH: DWORD = 0x00000004;
-pub const DM_PAPERWIDTH: DWORD = 0x00000008;
-pub const DM_SCALE: DWORD = 0x00000010;
-pub const DM_POSITION: DWORD = 0x00000020;
-pub const DM_NUP: DWORD = 0x00000040;
-pub const DM_DISPLAYORIENTATION: DWORD = 0x00000080;
-pub const DM_COPIES: DWORD = 0x00000100;
-pub const DM_DEFAULTSOURCE: DWORD = 0x00000200;
-pub const DM_PRINTQUALITY: DWORD = 0x00000400;
-pub const DM_COLOR: DWORD = 0x00000800;
-pub const DM_DUPLEX: DWORD = 0x00001000;
-pub const DM_YRESOLUTION: DWORD = 0x00002000;
-pub const DM_TTOPTION: DWORD = 0x00004000;
-pub const DM_COLLATE: DWORD = 0x00008000;
-pub const DM_FORMNAME: DWORD = 0x00010000;
-pub const DM_LOGPIXELS: DWORD = 0x00020000;
-pub const DM_BITSPERPEL: DWORD = 0x00040000;
-pub const DM_PELSWIDTH: DWORD = 0x00080000;
-pub const DM_PELSHEIGHT: DWORD = 0x00100000;
-pub const DM_DISPLAYFLAGS: DWORD = 0x00200000;
-pub const DM_DISPLAYFREQUENCY: DWORD = 0x00400000;
-pub const DM_ICMMETHOD: DWORD = 0x00800000;
-pub const DM_ICMINTENT: DWORD = 0x01000000;
-pub const DM_MEDIATYPE: DWORD = 0x02000000;
-pub const DM_DITHERTYPE: DWORD = 0x04000000;
-pub const DM_PANNINGWIDTH: DWORD = 0x08000000;
-pub const DM_PANNINGHEIGHT: DWORD = 0x10000000;
-pub const DM_DISPLAYFIXEDOUTPUT: DWORD = 0x20000000;
-
-// http://msdn.microsoft.com/en-us/library/windows/desktop/dd162609(v=vs.85).aspx
-pub const EDD_GET_DEVICE_INTERFACE_NAME: DWORD = 0x00000001;
-
-// ?
-pub const ENUM_CURRENT_SETTINGS: DWORD = -1;
-pub const ENUM_REGISTRY_SETTINGS: DWORD = -2;
-
-// http://msdn.microsoft.com/en-us/library/windows/desktop/ms679351(v=vs.85).aspx
-pub const FORMAT_MESSAGE_ALLOCATE_BUFFER: DWORD = 0x00000100;
-pub const FORMAT_MESSAGE_ARGUMENT_ARRAY: DWORD = 0x00002000;
-pub const FORMAT_MESSAGE_FROM_HMODULE: DWORD = 0x00000800;
-pub const FORMAT_MESSAGE_FROM_STRING: DWORD = 0x00000400;
-pub const FORMAT_MESSAGE_FROM_SYSTEM: DWORD = 0x00001000;
-pub const FORMAT_MESSAGE_IGNORE_INSERTS: DWORD = 0x00000200;
-
-// ?
-pub const PFD_TYPE_RGBA: BYTE = 0;
-pub const PFD_TYPE_COLORINDEX: BYTE = 1;
-pub const PFD_MAIN_PLANE: BYTE = 0;
-pub const PFD_OVERLAY_PLANE: BYTE = 1;
-pub const PFD_UNDERLAY_PLANE: BYTE = (-1);
-pub const PFD_DOUBLEBUFFER: DWORD = 0x00000001;
-pub const PFD_STEREO: DWORD = 0x00000002;
-pub const PFD_DRAW_TO_WINDOW: DWORD = 0x00000004;
-pub const PFD_DRAW_TO_BITMAP: DWORD = 0x00000008;
-pub const PFD_SUPPORT_GDI: DWORD = 0x00000010;
-pub const PFD_SUPPORT_OPENGL: DWORD = 0x00000020;
-pub const PFD_GENERIC_FORMAT: DWORD = 0x00000040;
-pub const PFD_NEED_PALETTE: DWORD = 0x00000080;
-pub const PFD_NEED_SYSTEM_PALETTE: DWORD = 0x00000100;
-pub const PFD_SWAP_EXCHANGE: DWORD = 0x00000200;
-pub const PFD_SWAP_COPY: DWORD = 0x00000400;
-pub const PFD_SWAP_LAYER_BUFFERS: DWORD = 0x00000800;
-pub const PFD_GENERIC_ACCELERATED: DWORD = 0x00001000;
-pub const PFD_SUPPORT_COMPOSITION: DWORD = 0x00008000;
-pub const PFD_DEPTH_DONTCARE: DWORD = 0x20000000;
-pub const PFD_DOUBLEBUFFER_DONTCARE: DWORD = 0x40000000;
-pub const PFD_STEREO_DONTCARE: DWORD = 0x80000000;
-
-// http://msdn.microsoft.com/en-us/library/windows/desktop/ms633548(v=vs.85).aspx
-pub const SW_FORCEMINIMIZE: libc::c_int = 11;
-pub const SW_HIDE: libc::c_int = 0;
-pub const SW_MAXIMIZE: libc::c_int = 3;
-pub const SW_MINIMIZE: libc::c_int = 6;
-pub const SW_RESTORE: libc::c_int = 9;
-pub const SW_SHOW: libc::c_int = 5;
-pub const SW_SHOWDEFAULT: libc::c_int = 10;
-pub const SW_SHOWMAXIMIZED: libc::c_int = 3;
-pub const SW_SHOWMINIMIZED: libc::c_int = 2;
-pub const SW_SHOWMINNOACTIVE: libc::c_int = 7;
-pub const SW_SHOWNA: libc::c_int = 8;
-pub const SW_SHOWNOACTIVATE: libc::c_int = 4;
-pub const SW_SHOWNORMAL: libc::c_int = 1;
-
-// http://msdn.microsoft.com/en-us/library/windows/desktop/ms633545(v=vs.85).aspx
-pub const SWP_ASYNCWINDOWPOS: UINT = 0x4000;
-pub const SWP_DEFERERASE: UINT = 0x2000;
-pub const SWP_DRAWFRAME: UINT = 0x0020;
-pub const SWP_FRAMECHANGED: UINT = 0x0020;
-pub const SWP_HIDEWINDOW: UINT = 0x0080;
-pub const SWP_NOACTIVATE: UINT = 0x0010;
-pub const SWP_NOCOPYBITS: UINT = 0x0100;
-pub const SWP_NOMOVE: UINT = 0x0002;
-pub const SWP_NOOWNERZORDER: UINT = 0x0200;
-pub const SWP_NOREDRAW: UINT = 0x0008;
-pub const SWP_NOREPOSITION: UINT = 0x0200;
-pub const SWP_NOSENDCHANGING: UINT = 0x0400;
-pub const SWP_NOSIZE: UINT = 0x0001;
-pub const SWP_NOZORDER: UINT = 0x0004;
-pub const SWP_SHOWWINDOW: UINT = 0x0040;
-
-// http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx
-pub const VK_LBUTTON: WPARAM = 0x01;
-pub const VK_RBUTTON: WPARAM = 0x02;
-pub const VK_CANCEL: WPARAM = 0x03;
-pub const VK_MBUTTON: WPARAM = 0x04;
-pub const VK_XBUTTON1: WPARAM = 0x05;
-pub const VK_XBUTTON2: WPARAM = 0x06;
-pub const VK_BACK: WPARAM = 0x08;
-pub const VK_TAB: WPARAM = 0x09;
-pub const VK_CLEAR: WPARAM = 0x0C;
-pub const VK_RETURN: WPARAM = 0x0D;
-pub const VK_SHIFT: WPARAM = 0x10;
-pub const VK_CONTROL: WPARAM = 0x11;
-pub const VK_MENU: WPARAM = 0x12;
-pub const VK_PAUSE: WPARAM = 0x13;
-pub const VK_CAPITAL: WPARAM = 0x14;
-pub const VK_KANA: WPARAM = 0x15;
-pub const VK_HANGUEL: WPARAM = 0x15;
-pub const VK_HANGUL: WPARAM = 0x15;
-pub const VK_JUNJA: WPARAM = 0x17;
-pub const VK_FINAL: WPARAM = 0x18;
-pub const VK_HANJA: WPARAM = 0x19;
-pub const VK_KANJI: WPARAM = 0x19;
-pub const VK_ESCAPE: WPARAM = 0x1B;
-pub const VK_CONVERT: WPARAM = 0x1C;
-pub const VK_NONCONVERT: WPARAM = 0x1D;
-pub const VK_ACCEPT: WPARAM = 0x1E;
-pub const VK_MODECHANGE: WPARAM = 0x1F;
-pub const VK_SPACE: WPARAM = 0x20;
-pub const VK_PRIOR: WPARAM = 0x21;
-pub const VK_NEXT: WPARAM = 0x22;
-pub const VK_END: WPARAM = 0x23;
-pub const VK_HOME: WPARAM = 0x24;
-pub const VK_LEFT: WPARAM = 0x25;
-pub const VK_UP: WPARAM = 0x26;
-pub const VK_RIGHT: WPARAM = 0x27;
-pub const VK_DOWN: WPARAM = 0x28;
-pub const VK_SELECT: WPARAM = 0x29;
-pub const VK_PRINT: WPARAM = 0x2A;
-pub const VK_EXECUTE: WPARAM = 0x2B;
-pub const VK_SNAPSHOT: WPARAM = 0x2C;
-pub const VK_INSERT: WPARAM = 0x2D;
-pub const VK_DELETE: WPARAM = 0x2E;
-pub const VK_HELP: WPARAM = 0x2F;
-pub const VK_LWIN: WPARAM = 0x5B;
-pub const VK_RWIN: WPARAM = 0x5C;
-pub const VK_APPS: WPARAM = 0x5D;
-pub const VK_SLEEP: WPARAM = 0x5F;
-pub const VK_NUMPAD0: WPARAM = 0x60;
-pub const VK_NUMPAD1: WPARAM = 0x61;
-pub const VK_NUMPAD2: WPARAM = 0x62;
-pub const VK_NUMPAD3: WPARAM = 0x63;
-pub const VK_NUMPAD4: WPARAM = 0x64;
-pub const VK_NUMPAD5: WPARAM = 0x65;
-pub const VK_NUMPAD6: WPARAM = 0x66;
-pub const VK_NUMPAD7: WPARAM = 0x67;
-pub const VK_NUMPAD8: WPARAM = 0x68;
-pub const VK_NUMPAD9: WPARAM = 0x69;
-pub const VK_MULTIPLY: WPARAM = 0x6A;
-pub const VK_ADD: WPARAM = 0x6B;
-pub const VK_SEPARATOR: WPARAM = 0x6C;
-pub const VK_SUBTRACT: WPARAM = 0x6D;
-pub const VK_DECIMAL: WPARAM = 0x6E;
-pub const VK_DIVIDE: WPARAM = 0x6F;
-pub const VK_F1: WPARAM = 0x70;
-pub const VK_F2: WPARAM = 0x71;
-pub const VK_F3: WPARAM = 0x72;
-pub const VK_F4: WPARAM = 0x73;
-pub const VK_F5: WPARAM = 0x74;
-pub const VK_F6: WPARAM = 0x75;
-pub const VK_F7: WPARAM = 0x76;
-pub const VK_F8: WPARAM = 0x77;
-pub const VK_F9: WPARAM = 0x78;
-pub const VK_F10: WPARAM = 0x79;
-pub const VK_F11: WPARAM = 0x7A;
-pub const VK_F12: WPARAM = 0x7B;
-pub const VK_F13: WPARAM = 0x7C;
-pub const VK_F14: WPARAM = 0x7D;
-pub const VK_F15: WPARAM = 0x7E;
-pub const VK_F16: WPARAM = 0x7F;
-pub const VK_F17: WPARAM = 0x80;
-pub const VK_F18: WPARAM = 0x81;
-pub const VK_F19: WPARAM = 0x82;
-pub const VK_F20: WPARAM = 0x83;
-pub const VK_F21: WPARAM = 0x84;
-pub const VK_F22: WPARAM = 0x85;
-pub const VK_F23: WPARAM = 0x86;
-pub const VK_F24: WPARAM = 0x87;
-pub const VK_NUMLOCK: WPARAM = 0x90;
-pub const VK_SCROLL: WPARAM = 0x91;
-pub const VK_LSHIFT: WPARAM = 0xA0;
-pub const VK_RSHIFT: WPARAM = 0xA1;
-pub const VK_LCONTROL: WPARAM = 0xA2;
-pub const VK_RCONTROL: WPARAM = 0xA3;
-pub const VK_LMENU: WPARAM = 0xA4;
-pub const VK_RMENU: WPARAM = 0xA5;
-pub const VK_BROWSER_BACK: WPARAM = 0xA6;
-pub const VK_BROWSER_FORWARD: WPARAM = 0xA7;
-pub const VK_BROWSER_REFRESH: WPARAM = 0xA8;
-pub const VK_BROWSER_STOP: WPARAM = 0xA9;
-pub const VK_BROWSER_SEARCH: WPARAM = 0xAA;
-pub const VK_BROWSER_FAVORITES: WPARAM = 0xAB;
-pub const VK_BROWSER_HOME: WPARAM = 0xAC;
-pub const VK_VOLUME_MUTE: WPARAM = 0xAD;
-pub const VK_VOLUME_DOWN: WPARAM = 0xAE;
-pub const VK_VOLUME_UP: WPARAM = 0xAF;
-pub const VK_MEDIA_NEXT_TRACK: WPARAM = 0xB0;
-pub const VK_MEDIA_PREV_TRACK: WPARAM = 0xB1;
-pub const VK_MEDIA_STOP: WPARAM = 0xB2;
-pub const VK_MEDIA_PLAY_PAUSE: WPARAM = 0xB3;
-pub const VK_LAUNCH_MAIL: WPARAM = 0xB4;
-pub const VK_LAUNCH_MEDIA_SELECT: WPARAM = 0xB5;
-pub const VK_LAUNCH_APP1: WPARAM = 0xB6;
-pub const VK_LAUNCH_APP2: WPARAM = 0xB7;
-pub const VK_OEM_1: WPARAM = 0xBA;
-pub const VK_OEM_PLUS: WPARAM = 0xBB;
-pub const VK_OEM_COMMA: WPARAM = 0xBC;
-pub const VK_OEM_MINUS: WPARAM = 0xBD;
-pub const VK_OEM_PERIOD: WPARAM = 0xBE;
-pub const VK_OEM_2: WPARAM = 0xBF;
-pub const VK_OEM_3: WPARAM = 0xC0;
-pub const VK_OEM_4: WPARAM = 0xDB;
-pub const VK_OEM_5: WPARAM = 0xDC;
-pub const VK_OEM_6: WPARAM = 0xDD;
-pub const VK_OEM_7: WPARAM = 0xDE;
-pub const VK_OEM_8: WPARAM = 0xDF;
-pub const VK_OEM_102: WPARAM = 0xE2;
-pub const VK_PROCESSKEY: WPARAM = 0xE5;
-pub const VK_PACKET: WPARAM = 0xE7;
-pub const VK_ATTN: WPARAM = 0xF6;
-pub const VK_CRSEL: WPARAM = 0xF7;
-pub const VK_EXSEL: WPARAM = 0xF8;
-pub const VK_EREOF: WPARAM = 0xF9;
-pub const VK_PLAY: WPARAM = 0xFA;
-pub const VK_ZOOM: WPARAM = 0xFB;
-pub const VK_NONAME: WPARAM = 0xFC;
-pub const VK_PA1: WPARAM = 0xFD;
-pub const VK_OEM_CLEAR: WPARAM = 0xFE;
-
-// messages
-pub const WM_LBUTTONDOWN: UINT = 0x0201;
-pub const WM_LBUTTONUP: UINT = 0x0202;
-pub const WM_CHAR: UINT = 0x0102;
-pub const WM_COMMAND: UINT = 0x0111;
-pub const WM_DESTROY: UINT = 0x0002;
-pub const WM_ERASEBKGND: UINT = 0x0014;
-pub const WM_KEYDOWN: UINT = 0x0100;
-pub const WM_KEYUP: UINT = 0x0101;
-pub const WM_KILLFOCUS: UINT = 0x0008;
-pub const WM_MBUTTONDOWN: UINT = 0x0207;
-pub const WM_MBUTTONUP: UINT = 0x0208;
-pub const WM_MOUSEMOVE: UINT = 0x0200;
-pub const WM_MOUSEWHEEL: UINT = 0x020A;
-pub const WM_MOVE: UINT = 0x0003;
-pub const WM_PAINT: UINT = 0x000F;
-pub const WM_RBUTTONDOWN: UINT = 0x0204;
-pub const WM_RBUTTONUP: UINT = 0x0205;
-pub const WM_SETFOCUS: UINT = 0x0007;
-pub const WM_SIZE: UINT = 0x0005;
-pub const WM_SIZING: UINT = 0x0214;
-
-// http://msdn.microsoft.com/en-us/library/windows/desktop/ms632600(v=vs.85).aspx
-pub const WS_BORDER: DWORD = 0x00800000;
-pub const WS_CAPTION: DWORD = 0x00C00000;
-pub const WS_CHILD: DWORD = 0x40000000;
-pub const WS_CHILDWINDOW: DWORD = 0x40000000;
-pub const WS_CLIPCHILDREN: DWORD = 0x02000000;
-pub const WS_CLIPSIBLINGS: DWORD = 0x04000000;
-pub const WS_DISABLED: DWORD = 0x08000000;
-pub const WS_DLGFRAME: DWORD = 0x00400000;
-pub const WS_GROUP: DWORD = 0x00020000;
-pub const WS_HSCROLL: DWORD = 0x00100000;
-pub const WS_ICONIC: DWORD = 0x20000000;
-pub const WS_MAXIMIZE: DWORD = 0x01000000;
-pub const WS_MAXIMIZEBOX: DWORD = 0x00010000;
-pub const WS_MINIMIZE: DWORD = 0x20000000;
-pub const WS_MINIMIZEBOX: DWORD = 0x00020000;
-pub const WS_OVERLAPPED: DWORD = 0x00000000;
-pub const WS_OVERLAPPEDWINDOW: DWORD = (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX);
-pub const WS_POPUP: DWORD = 0x80000000;
-pub const WS_POPUPWINDOW: DWORD = (WS_POPUP | WS_BORDER | WS_SYSMENU);
-pub const WS_SIZEBOX: DWORD = 0x00040000;
-pub const WS_SYSMENU: DWORD = 0x00080000;
-pub const WS_TABSTOP: DWORD = 0x00010000;
-pub const WS_THICKFRAME: DWORD = 0x00040000;
-pub const WS_TILED: DWORD = 0x00000000;
-pub const WS_TILEDWINDOW: DWORD = (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX);
-pub const WS_VISIBLE: DWORD = 0x10000000;
-pub const WS_VSCROLL: DWORD = 0x00200000;
-
-// http://msdn.microsoft.com/en-us/library/windows/desktop/ff700543(v=vs.85).aspx
-pub const WS_EX_ACCEPTFILES: DWORD = 0x00000010;
-pub const WS_EX_APPWINDOW: DWORD = 0x00040000;
-pub const WS_EX_CLIENTEDGE: DWORD = 0x00000200;
-pub const WS_EX_COMPOSITED: DWORD = 0x02000000;
-pub const WS_EX_CONTEXTHELP: DWORD = 0x00000400;
-pub const WS_EX_CONTROLPARENT: DWORD = 0x00010000;
-pub const WS_EX_DLGMODALFRAME: DWORD = 0x00000001;
-pub const WS_EX_LAYERED: DWORD = 0x00080000;
-pub const WS_EX_LAYOUTRTL: DWORD = 0x00400000;
-pub const WS_EX_LEFT: DWORD = 0x00000000;
-pub const WS_EX_LEFTSCROLLBAR: DWORD = 0x00004000;
-pub const WS_EX_LTRREADING: DWORD = 0x00000000;
-pub const WS_EX_MDICHILD: DWORD = 0x00000040;
-pub const WS_EX_NOACTIVATE: DWORD = 0x08000000;
-pub const WS_EX_NOINHERITLAYOUT: DWORD = 0x00100000;
-pub const WS_EX_NOPARENTNOTIFY: DWORD = 0x00000004;
-pub const WS_EX_NOREDIRECTIONBITMAP: DWORD = 0x00200000;
-pub const WS_EX_OVERLAPPEDWINDOW: DWORD = (WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE);
-pub const WS_EX_PALETTEWINDOW: DWORD = (WS_EX_WINDOWEDGE | WS_EX_TOOLWINDOW | WS_EX_TOPMOST);
-pub const WS_EX_RIGHT: DWORD = 0x00001000;
-pub const WS_EX_RIGHTSCROLLBAR: DWORD = 0x00000000;
-pub const WS_EX_RTLREADING: DWORD = 0x00002000;
-pub const WS_EX_STATICEDGE: DWORD = 0x00020000;
-pub const WS_EX_TOOLWINDOW: DWORD = 0x00000080;
-pub const WS_EX_TOPMOST: DWORD = 0x00000008;
-pub const WS_EX_TRANSPARENT: DWORD = 0x00000020;
-pub const WS_EX_WINDOWEDGE: DWORD = 0x00000100;
-
-// http://msdn.microsoft.com/en-us/library/windows/desktop/ms633573(v=vs.85).aspx
-pub type WNDPROC = extern "stdcall" fn(HWND, UINT, WPARAM, LPARAM) -> LRESULT;
-
-// ?
-pub type HGLRC = HANDLE;
-
-// http://msdn.microsoft.com/en-us/library/windows/desktop/ms633577(v=vs.85).aspx
-#[repr(C)]
-pub struct WNDCLASSEX {
- pub cbSize: UINT,
- pub style: UINT,
- pub lpfnWndProc: WNDPROC,
- pub cbClsExtra: libc::c_int,
- pub cbWndExtra: libc::c_int,
- pub hInstance: HINSTANCE,
- pub hIcon: HICON,
- pub hCursor: HCURSOR,
- pub hbrBackground: HBRUSH,
- pub lpszMenuName: LPCWSTR,
- pub lpszClassName: LPCWSTR,
- pub hIconSm: HICON,
-}
-
-// http://msdn.microsoft.com/en-us/library/windows/desktop/dd162805(v=vs.85).aspxtag
-#[repr(C)]
-pub struct POINT {
- pub x: LONG,
- pub y: LONG,
-}
-
-// http://msdn.microsoft.com/en-us/library/windows/desktop/ms644958(v=vs.85).aspx
-#[repr(C)]
-pub struct MSG {
- pub hwnd: HWND,
- pub message: UINT,
- pub wParam: WPARAM,
- pub lParam: LPARAM,
- pub time: DWORD,
- pub pt: POINT,
-}
-
-// http://msdn.microsoft.com/en-us/library/windows/desktop/dd162768(v=vs.85).aspx
-#[repr(C)]
-pub struct PAINTSTRUCT {
- pub hdc: HDC,
- pub fErase: BOOL,
- pub rcPaint: RECT,
- pub fRestore: BOOL,
- pub fIncUpdate: BOOL,
- pub rgbReserved: [BYTE, ..32],
-}
-
-// http://msdn.microsoft.com/en-us/library/windows/desktop/dd162897(v=vs.85).aspx
-#[repr(C)]
-pub struct RECT {
- pub left: LONG,
- pub top: LONG,
- pub right: LONG,
- pub bottom: LONG,
-}
-
-// http://msdn.microsoft.com/en-us/library/windows/desktop/dd368826(v=vs.85).aspx
-#[repr(C)]
-pub struct PIXELFORMATDESCRIPTOR {
- pub nSize: WORD,
- pub nVersion: WORD,
- pub dwFlags: DWORD,
- pub iPixelType: BYTE,
- pub cColorBits: BYTE,
- pub cRedBits: BYTE,
- pub cRedShift: BYTE,
- pub cGreenBits: BYTE,
- pub cGreenShift: BYTE,
- pub cBlueBits: BYTE,
- pub cBlueShift: BYTE,
- pub cAlphaBits: BYTE,
- pub cAlphaShift: BYTE,
- pub cAccumBits: BYTE,
- pub cAccumRedBits: BYTE,
- pub cAccumGreenBits: BYTE,
- pub cAccumBlueBits: BYTE,
- pub cAccumAlphaBits: BYTE,
- pub cDepthBits: BYTE,
- pub cStencilBits: BYTE,
- pub cAuxBuffers: BYTE,
- pub iLayerType: BYTE,
- pub bReserved: BYTE,
- pub dwLayerMask: DWORD,
- pub dwVisibleMask: DWORD,
- pub dwDamageMask: DWORD,
-}
-
-// http://msdn.microsoft.com/en-us/library/dd162807(v=vs.85).aspx
-#[repr(C)]
-pub struct POINTL {
- pub x: LONG,
- pub y: LONG,
-}
-
-// http://msdn.microsoft.com/en-us/library/windows/desktop/dd183565(v=vs.85).aspx
-#[repr(C)]
-pub struct DEVMODE {
- pub dmDeviceName: [WCHAR, ..32],
- pub dmSpecVersion: WORD,
- pub dmDriverVersion: WORD,
- pub dmSize: WORD,
- pub dmDriverExtra: WORD,
- pub dmFields: DWORD,
- pub union1: [u8, ..16],
- pub dmColor: libc::c_short,
- pub dmDuplex: libc::c_short,
- pub dmYResolution: libc::c_short,
- pub dmTTOption: libc::c_short,
- pub dmCollate: libc::c_short,
- pub dmFormName: [WCHAR, ..32],
- pub dmLogPixels: WORD,
- pub dmBitsPerPel: DWORD,
- pub dmPelsWidth: DWORD,
- pub dmPelsHeight: DWORD,
- pub dmDisplayFlags: DWORD,
- pub dmDisplayFrequency: DWORD,
- pub dmICMMethod: DWORD,
- pub dmICMIntent: DWORD,
- pub dmMediaType: DWORD,
- pub dmDitherType: DWORD,
- dmReserved1: DWORD,
- dmReserved2: DWORD,
- pub dmPanningWidth: DWORD,
- pub dmPanningHeight: DWORD,
-}
-
-// http://msdn.microsoft.com/en-us/library/windows/desktop/ms632611(v=vs.85).aspx
-#[repr(C)]
-pub struct WINDOWPLACEMENT {
- pub length: UINT,
- pub flags: UINT,
- pub showCmd: UINT,
- pub ptMinPosition: POINT,
- pub ptMaxPosition: POINT,
- pub rcNormalPosition: RECT,
-}
-
-// http://msdn.microsoft.com/en-us/library/windows/desktop/dd183569(v=vs.85).aspx
-#[repr(C)]
-pub struct DISPLAY_DEVICEW {
- pub cb: DWORD,
- pub DeviceName: [WCHAR, ..32],
- pub DeviceString: [WCHAR, ..128],
- pub StateFlags: DWORD,
- pub DeviceID: [WCHAR, ..128],
- pub DeviceKey: [WCHAR, ..128],
-}
-
-pub type LPMSG = *mut MSG;
-
-#[link(name = "gdi32")]
-#[link(name = "Opengl32")]
-extern "system" {
- // http://msdn.microsoft.com/en-us/library/windows/desktop/ms632667(v=vs.85).aspx
- pub fn AdjustWindowRectEx(lpRect: *mut RECT, dwStyle: DWORD, bMenu: BOOL,
- dwExStyle: DWORD) -> BOOL;
-
- // http://msdn.microsoft.com/en-us/library/windows/desktop/dd183362(v=vs.85).aspx
- pub fn BeginPaint(hwnd: HWND, lpPaint: *mut PAINTSTRUCT) -> HDC;
-
- // http://msdn.microsoft.com/en-us/library/windows/desktop/dd183411(v=vs.85).aspx
- pub fn ChangeDisplaySettingsW(lpDevMode: *mut DEVMODE, dwFlags: DWORD) -> LONG;
-
- // http://msdn.microsoft.com/en-us/library/windows/desktop/dd183413(v=vs.85).aspx
- pub fn ChangeDisplaySettingsExW(lpszDeviceName: LPCWSTR, lpDevMode: *mut DEVMODE, hwnd: HWND,
- dwFlags: DWORD, lParam: LPVOID) -> LONG;
-
- // http://msdn.microsoft.com/en-us/library/dd318284(v=vs.85).aspx
- pub fn ChoosePixelFormat(hdc: HDC, ppfd: *const PIXELFORMATDESCRIPTOR) -> libc::c_int;
-
- // http://msdn.microsoft.com/en-us/library/windows/desktop/ms632680(v=vs.85).aspx
- pub fn CreateWindowExW(dwExStyle: DWORD, lpClassName: LPCWSTR, lpWindowName: LPCWSTR,
- dwStyle: DWORD, x: libc::c_int, y: libc::c_int, nWidth: libc::c_int, nHeight: libc::c_int,
- hWndParent: HWND, hMenu: HMENU, hInstance: HINSTANCE, lpParam: LPVOID) -> HWND;
-
- // http://msdn.microsoft.com/en-us/library/windows/desktop/ms633572(v=vs.85).aspx
- pub fn DefWindowProcW(hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM) -> LRESULT;
-
- // http://msdn.microsoft.com/en-us/library/windows/desktop/dd318302(v=vs.85).aspx
- pub fn DescribePixelFormat(hdc: HDC, iPixelFormat: libc::c_int, nBytes: UINT,
- ppfd: *mut PIXELFORMATDESCRIPTOR) -> libc::c_int;
-
- // http://msdn.microsoft.com/en-us/library/windows/desktop/ms632682(v=vs.85).aspx
- pub fn DestroyWindow(hWnd: HWND) -> BOOL;
-
- // http://msdn.microsoft.com/en-us/library/windows/desktop/ms644934(v=vs.85).aspx
- pub fn DispatchMessageW(lpmsg: *const MSG) -> LRESULT;
-
- // http://msdn.microsoft.com/en-us/library/windows/desktop/dd162598(v=vs.85).aspx
- pub fn EndPaint(hWnd: HWND, lpPaint: *const PAINTSTRUCT) -> BOOL;
-
- // http://msdn.microsoft.com/en-us/library/windows/desktop/dd162609(v=vs.85).aspx
- pub fn EnumDisplayDevicesW(lpDevice: LPCWSTR, iDevNum: DWORD,
- lpDisplayDevice: *mut DISPLAY_DEVICEW, dwFlags: DWORD) -> BOOL;
-
- // http://msdn.microsoft.com/en-us/library/dd162612(v=vs.85).aspx
- pub fn EnumDisplaySettingsExW(lpszDeviceName: LPCWSTR, iModeNum: DWORD,
- lpDevMode: *mut DEVMODE, dwFlags: DWORD) -> BOOL;
-
- // http://msdn.microsoft.com/en-us/library/windows/desktop/dd162719(v=vs.85).aspx
- pub fn FillRect(hDC: HDC, lprc: *const RECT, hbr: HBRUSH) -> libc::c_int;
-
- // http://msdn.microsoft.com/en-us/library/windows/desktop/ms633503(v=vs.85).aspx
- pub fn GetClientRect(hWnd: HWND, lpRect: *mut RECT) -> BOOL;
-
- // http://msdn.microsoft.com/en-us/library/dd144871(v=vs.85).aspx
- pub fn GetDC(hWnd: HWND) -> HDC;
-
- // http://msdn.microsoft.com/en-us/library/windows/desktop/ms679360(v=vs.85).aspx
- pub fn GetLastError() -> DWORD;
-
- // http://msdn.microsoft.com/en-us/library/windows/desktop/ms644936(v=vs.85).aspx
- pub fn GetMessageW(lpMsg: LPMSG, hWnd: HWND, wMsgFilterMin: UINT, wMsgFilterMax: UINT) -> BOOL;
-
- // http://msdn.microsoft.com/en-us/library/windows/desktop/ms683199(v=vs.85).aspx
- pub fn GetModuleHandleW(lpModuleName: LPCWSTR) -> HMODULE;
-
- // http://msdn.microsoft.com/en-us/library/windows/desktop/ms683212(v=vs.85).aspx
- pub fn GetProcAddress(hModule: HMODULE, lpProcName: LPCSTR) -> *const libc::c_void;
-
- // http://msdn.microsoft.com/en-us/library/windows/desktop/ms633518(v=vs.85).aspx
- pub fn GetWindowPlacement(hWnd: HWND, lpwndpl: *mut WINDOWPLACEMENT) -> BOOL;
-
- // http://msdn.microsoft.com/en-us/library/windows/desktop/ms633519(v=vs.85).aspx
- pub fn GetWindowRect(hWnd: HWND, lpRect: *mut RECT) -> BOOL;
-
- // http://msdn.microsoft.com/en-us/library/windows/desktop/ms684175(v=vs.85).aspx
- pub fn LoadLibraryW(lpFileName: LPCWSTR) -> HMODULE;
-
- // http://msdn.microsoft.com/en-us/library/windows/desktop/aa366730(v=vs.85).aspx
- pub fn LocalFree(hMem: HLOCAL) -> HLOCAL;
-
- // http://msdn.microsoft.com/en-us/library/windows/desktop/ms644943(v=vs.85).aspx
- pub fn PeekMessageW(lpMsg: *mut MSG, hWnd: HWND, wMsgFilterMin: UINT, wMsgFilterMax: UINT,
- wRemoveMsg: UINT) -> BOOL;
-
- // http://msdn.microsoft.com/en-us/library/windows/desktop/ms644944(v=vs.85).aspx
- pub fn PostMessageW(hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM) -> BOOL;
-
- // http://msdn.microsoft.com/en-us/library/windows/desktop/ms644945(v=vs.85).aspx
- pub fn PostQuitMessage(nExitCode: libc::c_int);
-
- // http://msdn.microsoft.com/en-us/library/windows/desktop/ms633586(v=vs.85).aspx
- pub fn RegisterClassExW(lpWndClass: *const WNDCLASSEX) -> ATOM;
-
- // http://msdn.microsoft.com/en-us/library/windows/desktop/ms633539(v=vs.85).aspx
- pub fn SetForegroundWindow(hWnd: HWND) -> BOOL;
-
- // http://msdn.microsoft.com/en-us/library/windows/desktop/dd369049(v=vs.85).aspx
- pub fn SetPixelFormat(hdc: HDC, iPixelFormat: libc::c_int,
- ppfd: *const PIXELFORMATDESCRIPTOR) -> BOOL;
-
- // http://msdn.microsoft.com/en-us/library/windows/desktop/ms633545(v=vs.85).aspx
- pub fn SetWindowPos(hWnd: HWND, hWndInsertAfter: HWND, X: libc::c_int, Y: libc::c_int,
- cx: libc::c_int, cy: libc::c_int, uFlags: UINT) -> BOOL;
-
- // http://msdn.microsoft.com/en-us/library/windows/desktop/ms633546(v=vs.85).aspx
- pub fn SetWindowTextW(hWnd: HWND, lpString: LPCWSTR) -> BOOL;
-
- // http://msdn.microsoft.com/en-us/library/windows/desktop/ms633548(v=vs.85).aspx
- pub fn ShowWindow(hWnd: HWND, nCmdShow: libc::c_int) -> BOOL;
-
- // http://msdn.microsoft.com/en-us/library/windows/desktop/dd369060(v=vs.85).aspx
- pub fn SwapBuffers(hdc: HDC) -> BOOL;
-
- // http://msdn.microsoft.com/en-us/library/windows/desktop/ms644934(v=vs.85).aspx
- pub fn TranslateMessage(lpmsg: *const MSG) -> BOOL;
-
- // http://msdn.microsoft.com/en-us/library/dd145167(v=vs.85).aspx
- pub fn UpdateWindow(hWnd: HWND) -> BOOL;
-
- // http://msdn.microsoft.com/en-us/library/windows/desktop/ms644956(v=vs.85).aspx
- pub fn WaitMessage() -> BOOL;
-}
diff --git a/src/win32/gl.rs b/src/win32/gl.rs
new file mode 100644
index 0000000..a44af77
--- /dev/null
+++ b/src/win32/gl.rs
@@ -0,0 +1,26 @@
+/// WGL bindings
+pub mod wgl {
+ generate_gl_bindings! {
+ api: "wgl",
+ profile: "core",
+ version: "1.0",
+ generator: "static"
+ }
+}
+
+/// Functions that are not necessarly always available
+pub mod wgl_extra {
+ generate_gl_bindings! {
+ api: "wgl",
+ profile: "core",
+ version: "1.0",
+ generator: "struct",
+ extensions: [
+ "WGL_ARB_create_context",
+ "WGL_EXT_swap_control"
+ ]
+ }
+}
+
+#[link(name = "opengl32")]
+extern {}
diff --git a/src/win32/init.rs b/src/win32/init.rs
index 7832268..f3e669c 100644
--- a/src/win32/init.rs
+++ b/src/win32/init.rs
@@ -1,6 +1,6 @@
use std::sync::atomic::AtomicBool;
use std::ptr;
-use super::{event, ffi};
+use super::event;
use super::Window;
use {CreationError, Event};
use CreationError::OsError;
@@ -8,17 +8,21 @@ use CreationError::OsError;
use std::cell::RefCell;
use std::rc::Rc;
+use libc;
+use super::gl;
+use winapi;
+
/// Stores the current window and its events dispatcher.
///
/// We only have one window per thread. We still store the HWND in case where we
/// receive an event for another window.
-thread_local!(static WINDOW: Rc<RefCell<Option<(ffi::HWND, Sender<Event>)>>> = Rc::new(RefCell::new(None)))
+thread_local!(static WINDOW: Rc<RefCell<Option<(winapi::HWND, Sender<Event>)>>> = Rc::new(RefCell::new(None)))
pub fn new_window(builder_dimensions: Option<(uint, uint)>, builder_title: String,
builder_monitor: Option<super::MonitorID>,
builder_gl_version: Option<(uint, uint)>, builder_debug: bool,
builder_vsync: bool, builder_hidden: bool,
- builder_sharelists: Option<ffi::HGLRC>, builder_multisampling: Option<u16>)
+ builder_sharelists: Option<winapi::HGLRC>, builder_multisampling: Option<u16>)
-> Result<Window, CreationError>
{
use std::mem;
@@ -39,34 +43,34 @@ pub fn new_window(builder_dimensions: Option<(uint, uint)>, builder_title: Strin
let class_name: Vec<u16> = "Window Class".utf16_units().chain(Some(0).into_iter())
.collect::<Vec<u16>>();
- let class = ffi::WNDCLASSEX {
- cbSize: mem::size_of::<ffi::WNDCLASSEX>() as ffi::UINT,
- style: ffi::CS_HREDRAW | ffi::CS_VREDRAW | ffi::CS_OWNDC,
+ let class = winapi::WNDCLASSEXW {
+ cbSize: mem::size_of::<winapi::WNDCLASSEXW>() as winapi::UINT,
+ style: winapi::CS_HREDRAW | winapi::CS_VREDRAW | winapi::CS_OWNDC,
lpfnWndProc: callback,
cbClsExtra: 0,
cbWndExtra: 0,
- hInstance: unsafe { ffi::GetModuleHandleW(ptr::null()) },
- hIcon: ptr::null(),
- hCursor: ptr::null(),
- hbrBackground: ptr::null(),
+ hInstance: unsafe { winapi::GetModuleHandleW(ptr::null()) },
+ hIcon: ptr::null_mut(),
+ hCursor: ptr::null_mut(),
+ hbrBackground: ptr::null_mut(),
lpszMenuName: ptr::null(),
lpszClassName: class_name.as_ptr(),
- hIconSm: ptr::null(),
+ hIconSm: ptr::null_mut(),
};
// We ignore errors because registering the same window class twice would trigger
// an error, and because errors here are detected during CreateWindowEx anyway.
// Also since there is no weird element in the struct, there is no reason for this
// call to fail.
- unsafe { ffi::RegisterClassExW(&class) };
+ unsafe { winapi::RegisterClassExW(&class) };
class_name
};
// building a RECT object with coordinates
- let mut rect = ffi::RECT {
- left: 0, right: builder_dimensions.unwrap_or((1024, 768)).val0() as ffi::LONG,
- top: 0, bottom: builder_dimensions.unwrap_or((1024, 768)).val1() as ffi::LONG,
+ let mut rect = winapi::RECT {
+ left: 0, right: builder_dimensions.unwrap_or((1024, 768)).val0() as winapi::LONG,
+ top: 0, bottom: builder_dimensions.unwrap_or((1024, 768)).val1() as winapi::LONG,
};
// switching to fullscreen if necessary
@@ -78,24 +82,24 @@ pub fn new_window(builder_dimensions: Option<(uint, uint)>, builder_title: Strin
// adjusting the rect
{
let pos = monitor.get_position();
- rect.left += pos.val0() as ffi::LONG;
- rect.right += pos.val0() as ffi::LONG;
- rect.top += pos.val1() as ffi::LONG;
- rect.bottom += pos.val1() as ffi::LONG;
+ rect.left += pos.val0() as winapi::LONG;
+ rect.right += pos.val0() as winapi::LONG;
+ rect.top += pos.val1() as winapi::LONG;
+ rect.bottom += pos.val1() as winapi::LONG;
}
// changing device settings
- let mut screen_settings: ffi::DEVMODE = unsafe { mem::zeroed() };
- screen_settings.dmSize = mem::size_of::<ffi::DEVMODE>() as ffi::WORD;
- screen_settings.dmPelsWidth = (rect.right - rect.left) as ffi::DWORD;
- screen_settings.dmPelsHeight = (rect.bottom - rect.top) as ffi::DWORD;
+ let mut screen_settings: winapi::DEVMODEW = unsafe { mem::zeroed() };
+ screen_settings.dmSize = mem::size_of::<winapi::DEVMODEW>() as winapi::WORD;
+ screen_settings.dmPelsWidth = (rect.right - rect.left) as winapi::DWORD;
+ screen_settings.dmPelsHeight = (rect.bottom - rect.top) as winapi::DWORD;
screen_settings.dmBitsPerPel = 32; // TODO: ?
- screen_settings.dmFields = ffi::DM_BITSPERPEL | ffi::DM_PELSWIDTH | ffi::DM_PELSHEIGHT;
+ screen_settings.dmFields = winapi::DM_BITSPERPEL | winapi::DM_PELSWIDTH | winapi::DM_PELSHEIGHT;
- let result = unsafe { ffi::ChangeDisplaySettingsExW(monitor.get_system_name().as_ptr(),
- &mut screen_settings, ptr::null(), ffi::CDS_FULLSCREEN, ptr::null_mut()) };
+ let result = unsafe { winapi::ChangeDisplaySettingsExW(monitor.get_system_name().as_ptr(),
+ &mut screen_settings, ptr::null_mut(), winapi::CDS_FULLSCREEN, ptr::null_mut()) };
- if result != ffi::DISP_CHANGE_SUCCESSFUL {
+ if result != winapi::DISP_CHANGE_SUCCESSFUL {
tx.send(Err(OsError(format!("ChangeDisplaySettings failed: {}", result))));
return;
}
@@ -103,26 +107,26 @@ pub fn new_window(builder_dimensions: Option<(uint, uint)>, builder_title: Strin
// computing the style and extended style of the window
let (ex_style, style) = if builder_monitor.is_some() {
- (ffi::WS_EX_APPWINDOW, ffi::WS_POPUP | ffi::WS_CLIPSIBLINGS | ffi::WS_CLIPCHILDREN)
+ (winapi::WS_EX_APPWINDOW, winapi::WS_POPUP | winapi::WS_CLIPSIBLINGS | winapi::WS_CLIPCHILDREN)
} else {
- (ffi::WS_EX_APPWINDOW | ffi::WS_EX_WINDOWEDGE,
- ffi::WS_OVERLAPPEDWINDOW | ffi::WS_CLIPSIBLINGS | ffi::WS_CLIPCHILDREN)
+ (winapi::WS_EX_APPWINDOW | winapi::WS_EX_WINDOWEDGE,
+ winapi::WS_OVERLAPPEDWINDOW | winapi::WS_CLIPSIBLINGS | winapi::WS_CLIPCHILDREN)
};
// adjusting the window coordinates using the style
- unsafe { ffi::AdjustWindowRectEx(&mut rect, style, 0, ex_style) };
+ unsafe { winapi::AdjustWindowRectEx(&mut rect, style, 0, ex_style) };
// getting the address of wglCreateContextAttribsARB and the pixel format
// that we will use
let (extra_functions, pixel_format) = {
// creating a dummy invisible window for GL initialization
let dummy_window = unsafe {
- let handle = ffi::CreateWindowExW(ex_style, class_name.as_ptr(),
- title.as_ptr() as ffi::LPCWSTR,
- style | ffi::WS_CLIPSIBLINGS | ffi::WS_CLIPCHILDREN,
- ffi::CW_USEDEFAULT, ffi::CW_USEDEFAULT,
+ let handle = winapi::CreateWindowExW(ex_style, class_name.as_ptr(),
+ title.as_ptr() as winapi::LPCWSTR,
+ style | winapi::WS_CLIPSIBLINGS | winapi::WS_CLIPCHILDREN,
+ winapi::CW_USEDEFAULT, winapi::CW_USEDEFAULT,
rect.right - rect.left, rect.bottom - rect.top,
- ptr::null(), ptr::null(), ffi::GetModuleHandleW(ptr::null()),
+ ptr::null_mut(), ptr::null_mut(), winapi::GetModuleHandleW(ptr::null()),
ptr::null_mut());
if handle.is_null() {
@@ -137,11 +141,11 @@ pub fn new_window(builder_dimensions: Option<(uint, uint)>, builder_title: Strin
// getting the HDC of the dummy window
let dummy_hdc = {
- let hdc = unsafe { ffi::GetDC(dummy_window) };
+ let hdc = unsafe { winapi::GetDC(dummy_window) };
if hdc.is_null() {
tx.send(Err(OsError(format!("GetDC function failed: {}",
os::error_string(os::errno() as uint)))));
- unsafe { ffi::DestroyWindow(dummy_window); }
+ unsafe { winapi::DestroyWindow(dummy_window); }
return;
}
hdc
@@ -150,35 +154,35 @@ pub fn new_window(builder_dimensions: Option<(uint, uint)>, builder_title: Strin
// getting the pixel format that we will use
let pixel_format = {
// initializing a PIXELFORMATDESCRIPTOR that indicates what we want
- let mut output: ffi::PIXELFORMATDESCRIPTOR = unsafe { mem::zeroed() };
- output.nSize = mem::size_of::<ffi::PIXELFORMATDESCRIPTOR>() as ffi::WORD;
+ let mut output: winapi::PIXELFORMATDESCRIPTOR = unsafe { mem::zeroed() };
+ output.nSize = mem::size_of::<winapi::PIXELFORMATDESCRIPTOR>() as winapi::WORD;
output.nVersion = 1;
- output.dwFlags = ffi::PFD_DRAW_TO_WINDOW | ffi::PFD_DOUBLEBUFFER |
- ffi::PFD_SUPPORT_OPENGL | ffi::PFD_GENERIC_ACCELERATED;
- output.iPixelType = ffi::PFD_TYPE_RGBA;
+ output.dwFlags = winapi::PFD_DRAW_TO_WINDOW | winapi::PFD_DOUBLEBUFFER |
+ winapi::PFD_SUPPORT_OPENGL | winapi::PFD_GENERIC_ACCELERATED;
+ output.iPixelType = winapi::PFD_TYPE_RGBA;
output.cColorBits = 24;
output.cAlphaBits = 8;
output.cAccumBits = 0;
output.cDepthBits = 24;
output.cStencilBits = 8;
output.cAuxBuffers = 0;
- output.iLayerType = ffi::PFD_MAIN_PLANE;
+ output.iLayerType = winapi::PFD_MAIN_PLANE;
- let pf_index = unsafe { ffi::ChoosePixelFormat(dummy_hdc, &output) };
+ let pf_index = unsafe { winapi::ChoosePixelFormat(dummy_hdc, &output) };
if pf_index == 0 {
tx.send(Err(OsError(format!("ChoosePixelFormat function failed: {}",
os::error_string(os::errno() as uint)))));
- unsafe { ffi::DestroyWindow(dummy_window); }
+ unsafe { winapi::DestroyWindow(dummy_window); }
return;
}
- if unsafe { ffi::DescribePixelFormat(dummy_hdc, pf_index,
- mem::size_of::<ffi::PIXELFORMATDESCRIPTOR>() as ffi::UINT, &mut output) } == 0
+ if unsafe { winapi::DescribePixelFormat(dummy_hdc, pf_index,
+ mem::size_of::<winapi::PIXELFORMATDESCRIPTOR>() as winapi::UINT, &mut output) } == 0
{
tx.send(Err(OsError(format!("DescribePixelFormat function failed: {}",
os::error_string(os::errno() as uint)))));
- unsafe { ffi::DestroyWindow(dummy_window); }
+ unsafe { winapi::DestroyWindow(dummy_window); }
return;
}
@@ -187,45 +191,45 @@ pub fn new_window(builder_dimensions: Option<(uint, uint)>, builder_title: Strin
// calling SetPixelFormat
unsafe {
- if ffi::SetPixelFormat(dummy_hdc, 1, &pixel_format) == 0 {
+ if winapi::SetPixelFormat(dummy_hdc, 1, &pixel_format) == 0 {
tx.send(Err(OsError(format!("SetPixelFormat function failed: {}",
os::error_string(os::errno() as uint)))));
- ffi::DestroyWindow(dummy_window);
+ winapi::DestroyWindow(dummy_window);
return;
}
}
// creating the dummy OpenGL context
let dummy_context = {
- let ctxt = unsafe { ffi::wgl::CreateContext(dummy_hdc) };
+ let ctxt = unsafe { gl::wgl::CreateContext(dummy_hdc as *const libc::c_void) };
if ctxt.is_null() {
tx.send(Err(OsError(format!("wglCreateContext function failed: {}",
os::error_string(os::errno() as uint)))));
- unsafe { ffi::DestroyWindow(dummy_window); }
+ unsafe { winapi::DestroyWindow(dummy_window); }
return;
}
ctxt
};
// making context current
- unsafe { ffi::wgl::MakeCurrent(dummy_hdc, dummy_context); }
+ unsafe { gl::wgl::MakeCurrent(dummy_hdc as *const libc::c_void, dummy_context); }
// loading the extra WGL functions
- let extra_functions = ffi::wgl_extra::Wgl::load_with(|addr| {
+ let extra_functions = gl::wgl_extra::Wgl::load_with(|addr| {
unsafe {
addr.with_c_str(|s| {
use libc;
- ffi::wgl::GetProcAddress(s) as *const libc::c_void
+ gl::wgl::GetProcAddress(s) as *const libc::c_void
})
}
});
// removing current context
- unsafe { ffi::wgl::MakeCurrent(ptr::null(), ptr::null()); }
+ unsafe { gl::wgl::MakeCurrent(ptr::null(), ptr::null()); }
// destroying the context and the window
- unsafe { ffi::wgl::DeleteContext(dummy_context); }
- unsafe { ffi::DestroyWindow(dummy_window); }
+ unsafe { gl::wgl::DeleteContext(dummy_context); }
+ unsafe { winapi::DestroyWindow(dummy_window); }
// returning the address
(extra_functions, pixel_format)
@@ -242,16 +246,16 @@ pub fn new_window(builder_dimensions: Option<(uint, uint)>, builder_title: Strin
let style = if builder_hidden {
style
} else {
- style | ffi::WS_VISIBLE
+ style | winapi::WS_VISIBLE
};
- let handle = ffi::CreateWindowExW(ex_style, class_name.as_ptr(),
- title.as_ptr() as ffi::LPCWSTR,
- style | ffi::WS_CLIPSIBLINGS | ffi::WS_CLIPCHILDREN,
- if builder_monitor.is_some() { 0 } else { ffi::CW_USEDEFAULT },
- if builder_monitor.is_some() { 0 } else { ffi::CW_USEDEFAULT },
- width.unwrap_or(ffi::CW_USEDEFAULT), height.unwrap_or(ffi::CW_USEDEFAULT),
- ptr::null(), ptr::null(), ffi::GetModuleHandleW(ptr::null()),
+ let handle = winapi::CreateWindowExW(ex_style, class_name.as_ptr(),
+ title.as_ptr() as winapi::LPCWSTR,
+ style | winapi::WS_CLIPSIBLINGS | winapi::WS_CLIPCHILDREN,
+ if builder_monitor.is_some() { 0 } else { winapi::CW_USEDEFAULT },
+ if builder_monitor.is_some() { 0 } else { winapi::CW_USEDEFAULT },
+ width.unwrap_or(winapi::CW_USEDEFAULT), height.unwrap_or(winapi::CW_USEDEFAULT),
+ ptr::null_mut(), ptr::null_mut(), winapi::GetModuleHandleW(ptr::null()),
ptr::null_mut());
if handle.is_null() {
@@ -266,11 +270,11 @@ pub fn new_window(builder_dimensions: Option<(uint, uint)>, builder_title: Strin
// getting the HDC of the window
let hdc = {
- let hdc = unsafe { ffi::GetDC(real_window) };
+ let hdc = unsafe { winapi::GetDC(real_window) };
if hdc.is_null() {
tx.send(Err(OsError(format!("GetDC function failed: {}",
os::error_string(os::errno() as uint)))));
- unsafe { ffi::DestroyWindow(real_window); }
+ unsafe { winapi::DestroyWindow(real_window); }
return;
}
hdc
@@ -278,10 +282,10 @@ pub fn new_window(builder_dimensions: Option<(uint, uint)>, builder_title: Strin
// calling SetPixelFormat
unsafe {
- if ffi::SetPixelFormat(hdc, 1, &pixel_format) == 0 {
+ if winapi::SetPixelFormat(hdc, 1, &pixel_format) == 0 {
tx.send(Err(OsError(format!("SetPixelFormat function failed: {}",
os::error_string(os::errno() as uint)))));
- ffi::DestroyWindow(real_window);
+ winapi::DestroyWindow(real_window);
return;
}
}
@@ -294,29 +298,30 @@ pub fn new_window(builder_dimensions: Option<(uint, uint)>, builder_title: Strin
if builder_gl_version.is_some() {
let version = builder_gl_version.as_ref().unwrap();
- attributes.push(ffi::wgl_extra::CONTEXT_MAJOR_VERSION_ARB as libc::c_int);
+ attributes.push(gl::wgl_extra::CONTEXT_MAJOR_VERSION_ARB as libc::c_int);
attributes.push(version.val0() as libc::c_int);
- attributes.push(ffi::wgl_extra::CONTEXT_MINOR_VERSION_ARB as libc::c_int);
+ attributes.push(gl::wgl_extra::CONTEXT_MINOR_VERSION_ARB as libc::c_int);
attributes.push(version.val1() as libc::c_int);
}
if builder_debug {
- attributes.push(ffi::wgl_extra::CONTEXT_FLAGS_ARB as libc::c_int);
- attributes.push(ffi::wgl_extra::CONTEXT_DEBUG_BIT_ARB as libc::c_int);
+ attributes.push(gl::wgl_extra::CONTEXT_FLAGS_ARB as libc::c_int);
+ attributes.push(gl::wgl_extra::CONTEXT_DEBUG_BIT_ARB as libc::c_int);
}
attributes.push(0);
let ctxt = unsafe {
if extra_functions.CreateContextAttribsARB.is_loaded() {
- let share = if let Some(c) = builder_sharelists { c } else { ptr::null() };
- extra_functions.CreateContextAttribsARB(hdc, share,
+ let share = if let Some(c) = builder_sharelists { c } else { ptr::null_mut() };
+ extra_functions.CreateContextAttribsARB(hdc as *const libc::c_void,
+ share as *const libc::c_void,
attributes.as_slice().as_ptr())
} else {
- let ctxt = ffi::wgl::CreateContext(hdc);
+ let ctxt = gl::wgl::CreateContext(hdc as *const libc::c_void);
if let Some(c) = builder_sharelists {
- ffi::wgl::ShareLists(c, ctxt);
+ gl::wgl::ShareLists(c as *const libc::c_void, ctxt);
};
ctxt
}
@@ -325,7 +330,7 @@ pub fn new_window(builder_dimensions: Option<(uint, uint)>, builder_title: Strin
if ctxt.is_null() {
tx.send(Err(OsError(format!("OpenGL context creation failed: {}",
os::error_string(os::errno() as uint)))));
- unsafe { ffi::DestroyWindow(real_window); }
+ unsafe { winapi::DestroyWindow(real_window); }
return;
}
@@ -334,7 +339,7 @@ pub fn new_window(builder_dimensions: Option<(uint, uint)>, builder_title: Strin
// calling SetForegroundWindow if fullscreen
if builder_monitor.is_some() {
- unsafe { ffi::SetForegroundWindow(real_window) };
+ unsafe { winapi::SetForegroundWindow(real_window) };
}
// filling the WINDOW task-local storage
@@ -351,12 +356,12 @@ pub fn new_window(builder_dimensions: Option<(uint, uint)>, builder_title: Strin
let gl_library = {
let name = "opengl32.dll".utf16_units().chain(Some(0).into_iter())
.collect::<Vec<u16>>().as_ptr();
- let lib = unsafe { ffi::LoadLibraryW(name) };
+ let lib = unsafe { winapi::LoadLibraryW(name) };
if lib.is_null() {
tx.send(Err(OsError(format!("LoadLibrary function failed: {}",
os::error_string(os::errno() as uint)))));
- unsafe { ffi::wgl::DeleteContext(context); }
- unsafe { ffi::DestroyWindow(real_window); }
+ unsafe { gl::wgl::DeleteContext(context); }
+ unsafe { winapi::DestroyWindow(real_window); }
return;
}
lib
@@ -365,25 +370,25 @@ pub fn new_window(builder_dimensions: Option<(uint, uint)>, builder_title: Strin
// handling vsync
if builder_vsync {
if extra_functions.SwapIntervalEXT.is_loaded() {
- unsafe { ffi::wgl::MakeCurrent(hdc, context) };
+ unsafe { gl::wgl::MakeCurrent(hdc as *const libc::c_void, context) };
if unsafe { extra_functions.SwapIntervalEXT(1) } == 0 {
tx.send(Err(OsError(format!("wglSwapIntervalEXT failed"))));
- unsafe { ffi::wgl::DeleteContext(context); }
- unsafe { ffi::DestroyWindow(real_window); }
+ unsafe { gl::wgl::DeleteContext(context); }
+ unsafe { winapi::DestroyWindow(real_window); }
return;
}
// it is important to remove the current context, otherwise you get very weird
// errors
- unsafe { ffi::wgl::MakeCurrent(ptr::null(), ptr::null()); }
+ unsafe { gl::wgl::MakeCurrent(ptr::null(), ptr::null()); }
}
}
// building the struct
let window = Window{
window: real_window,
- hdc: hdc,
- context: context,
+ hdc: hdc as winapi::HDC,
+ context: context as winapi::HGLRC,
gl_library: gl_library,
events_receiver: events_receiver,
is_closed: AtomicBool::new(false),
@@ -397,12 +402,12 @@ pub fn new_window(builder_dimensions: Option<(uint, uint)>, builder_title: Strin
loop {
let mut msg = unsafe { mem::uninitialized() };
- if unsafe { ffi::GetMessageW(&mut msg, ptr::null(), 0, 0) } == 0 {
+ if unsafe { winapi::GetMessageW(&mut msg, ptr::null_mut(), 0, 0) } == 0 {
break;
}
- unsafe { ffi::TranslateMessage(&msg) };
- unsafe { ffi::DispatchMessageW(&msg) }; // calls `callback` (see below)
+ unsafe { winapi::TranslateMessage(&msg) };
+ unsafe { winapi::DispatchMessageW(&msg) }; // calls `callback` (see below)
}
});
@@ -410,7 +415,7 @@ pub fn new_window(builder_dimensions: Option<(uint, uint)>, builder_title: Strin
}
/// Checks that the window is the good one, and if so send the event to it.
-fn send_event(input_window: ffi::HWND, event: Event) {
+fn send_event(input_window: winapi::HWND, event: Event) {
WINDOW.with(|window| {
let window = window.borrow();
let stored = match *window {
@@ -431,11 +436,11 @@ fn send_event(input_window: ffi::HWND, event: Event) {
/// This is the callback that is called by `DispatchMessage` in the events loop.
///
/// Returning 0 tells the Win32 API that the message has been processed.
-extern "stdcall" fn callback(window: ffi::HWND, msg: ffi::UINT,
- wparam: ffi::WPARAM, lparam: ffi::LPARAM) -> ffi::LRESULT
+extern "system" fn callback(window: winapi::HWND, msg: winapi::UINT,
+ wparam: winapi::WPARAM, lparam: winapi::LPARAM) -> winapi::LRESULT
{
match msg {
- ffi::WM_DESTROY => {
+ winapi::WM_DESTROY => {
use events::Event::Closed;
WINDOW.with(|w| {
@@ -446,7 +451,7 @@ extern "stdcall" fn callback(window: ffi::HWND, msg: ffi::UINT,
};
if win == &window {
- unsafe { ffi::PostQuitMessage(0); }
+ unsafe { winapi::PostQuitMessage(0); }
}
});
@@ -454,27 +459,27 @@ extern "stdcall" fn callback(window: ffi::HWND, msg: ffi::UINT,
0
},
- ffi::WM_ERASEBKGND => {
+ winapi::WM_ERASEBKGND => {
1
},
- ffi::WM_SIZE => {
+ winapi::WM_SIZE => {
use events::Event::Resized;
- let w = ffi::LOWORD(lparam as ffi::DWORD) as uint;
- let h = ffi::HIWORD(lparam as ffi::DWORD) as uint;
+ let w = winapi::LOWORD(lparam as winapi::DWORD) as uint;
+ let h = winapi::HIWORD(lparam as winapi::DWORD) as uint;
send_event(window, Resized(w, h));
0
},
- ffi::WM_MOVE => {
+ winapi::WM_MOVE => {
use events::Event::Moved;
- let x = ffi::LOWORD(lparam as ffi::DWORD) as i16 as int;
- let y = ffi::HIWORD(lparam as ffi::DWORD) as i16 as int;
+ let x = winapi::LOWORD(lparam as winapi::DWORD) as i16 as int;
+ let y = winapi::HIWORD(lparam as winapi::DWORD) as i16 as int;
send_event(window, Moved(x, y));
0
},
- ffi::WM_CHAR => {
+ winapi::WM_CHAR => {
use std::mem;
use events::Event::ReceivedCharacter;
let chr: char = unsafe { mem::transmute(wparam as u32) };
@@ -482,18 +487,18 @@ extern "stdcall" fn callback(window: ffi::HWND, msg: ffi::UINT,
0
},
- ffi::WM_MOUSEMOVE => {
+ winapi::WM_MOUSEMOVE => {
use events::Event::MouseMoved;
- let x = ffi::GET_X_LPARAM(lparam) as int;
- let y = ffi::GET_Y_LPARAM(lparam) as int;
+ let x = winapi::GET_X_LPARAM(lparam) as int;
+ let y = winapi::GET_Y_LPARAM(lparam) as int;
send_event(window, MouseMoved((x, y)));
0
},
- ffi::WM_MOUSEWHEEL => {
+ winapi::WM_MOUSEWHEEL => {
use events::Event::MouseWheel;
let value = (wparam >> 16) as i16;
@@ -504,7 +509,7 @@ extern "stdcall" fn callback(window: ffi::HWND, msg: ffi::UINT,
0
},
- ffi::WM_KEYDOWN => {
+ winapi::WM_KEYDOWN => {
use events::Event::KeyboardInput;
use events::ElementState::Pressed;
let scancode = ((lparam >> 16) & 0xff) as u8;
@@ -513,7 +518,7 @@ extern "stdcall" fn callback(window: ffi::HWND, msg: ffi::UINT,
0
},
- ffi::WM_KEYUP => {
+ winapi::WM_KEYUP => {
use events::Event::KeyboardInput;
use events::ElementState::Released;
let scancode = ((lparam >> 16) & 0xff) as u8;
@@ -522,7 +527,7 @@ extern "stdcall" fn callback(window: ffi::HWND, msg: ffi::UINT,
0
},
- ffi::WM_LBUTTONDOWN => {
+ winapi::WM_LBUTTONDOWN => {
use events::Event::MouseInput;
use events::MouseButton::LeftMouseButton;
use events::ElementState::Pressed;
@@ -530,7 +535,7 @@ extern "stdcall" fn callback(window: ffi::HWND, msg: ffi::UINT,
0
},
- ffi::WM_LBUTTONUP => {
+ winapi::WM_LBUTTONUP => {
use events::Event::MouseInput;
use events::MouseButton::LeftMouseButton;
use events::ElementState::Released;
@@ -538,7 +543,7 @@ extern "stdcall" fn callback(window: ffi::HWND, msg: ffi::UINT,
0
},
- ffi::WM_RBUTTONDOWN => {
+ winapi::WM_RBUTTONDOWN => {
use events::Event::MouseInput;
use events::MouseButton::RightMouseButton;
use events::ElementState::Pressed;
@@ -546,7 +551,7 @@ extern "stdcall" fn callback(window: ffi::HWND, msg: ffi::UINT,
0
},
- ffi::WM_RBUTTONUP => {
+ winapi::WM_RBUTTONUP => {
use events::Event::MouseInput;
use events::MouseButton::RightMouseButton;
use events::ElementState::Released;
@@ -554,7 +559,7 @@ extern "stdcall" fn callback(window: ffi::HWND, msg: ffi::UINT,
0
},
- ffi::WM_MBUTTONDOWN => {
+ winapi::WM_MBUTTONDOWN => {
use events::Event::MouseInput;
use events::MouseButton::MiddleMouseButton;
use events::ElementState::Pressed;
@@ -562,7 +567,7 @@ extern "stdcall" fn callback(window: ffi::HWND, msg: ffi::UINT,
0
},
- ffi::WM_MBUTTONUP => {
+ winapi::WM_MBUTTONUP => {
use events::Event::MouseInput;
use events::MouseButton::MiddleMouseButton;
use events::ElementState::Released;
@@ -570,29 +575,29 @@ extern "stdcall" fn callback(window: ffi::HWND, msg: ffi::UINT,
0
},
- ffi::WM_SETFOCUS => {
+ winapi::WM_SETFOCUS => {
use events::Event::Focused;
send_event(window, Focused(true));
0
},
- ffi::WM_KILLFOCUS => {
+ winapi::WM_KILLFOCUS => {
use events::Event::Focused;
send_event(window, Focused(false));
0
},
_ => unsafe {
- ffi::DefWindowProcW(window, msg, wparam, lparam)
+ winapi::DefWindowProcW(window, msg, wparam, lparam)
}
}
}
-/*fn hints_to_pixelformat(hints: &Hints) -> ffi::PIXELFORMATDESCRIPTOR {
+/*fn hints_to_pixelformat(hints: &Hints) -> winapi::PIXELFORMATDESCRIPTOR {
use std::mem;
- ffi::PIXELFORMATDESCRIPTOR {
- nSize: size_of::<ffi::PIXELFORMATDESCRIPTOR>(),
+ winapi::PIXELFORMATDESCRIPTOR {
+ nSize: size_of::<winapi::PIXELFORMATDESCRIPTOR>(),
nVersion: 1,
dwFlags:
if hints.stereo { PFD_STEREO } else { 0 },
diff --git a/src/win32/mod.rs b/src/win32/mod.rs
index f08c033..8339cb1 100644
--- a/src/win32/mod.rs
+++ b/src/win32/mod.rs
@@ -11,8 +11,10 @@ use HeadlessRendererBuilder;
pub use self::monitor::{MonitorID, get_available_monitors, get_primary_monitor};
+use winapi;
+
mod event;
-mod ffi;
+mod gl;
mod init;
mod monitor;
@@ -44,19 +46,19 @@ impl HeadlessContext {
/// The Win32 implementation of the main `Window` object.
pub struct Window {
/// Main handle for the window.
- window: ffi::HWND,
+ window: winapi::HWND,
/// This represents a "draw context" for the surface of the window.
- hdc: ffi::HDC,
+ hdc: winapi::HDC,
/// OpenGL context.
- context: ffi::HGLRC,
+ context: winapi::HGLRC,
/// Binded to `opengl32.dll`.
///
/// `wglGetProcAddress` returns null for GL 1.1 functions because they are
/// already defined by the system. This module contains them.
- gl_library: ffi::HMODULE,
+ gl_library: winapi::HMODULE,
/// Receiver for the events dispatched by the window callback.
events_receiver: Receiver<Event>,
@@ -88,21 +90,21 @@ impl Window {
/// Calls SetWindowText on the HWND.
pub fn set_title(&self, text: &str) {
unsafe {
- ffi::SetWindowTextW(self.window,
+ winapi::SetWindowTextW(self.window,
text.utf16_units().chain(Some(0).into_iter())
- .collect::<Vec<u16>>().as_ptr() as ffi::LPCWSTR);
+ .collect::<Vec<u16>>().as_ptr() as winapi::LPCWSTR);
}
}
pub fn show(&self) {
unsafe {
- ffi::ShowWindow(self.window, ffi::SW_SHOW);
+ winapi::ShowWindow(self.window, winapi::SW_SHOW);
}
}
pub fn hide(&self) {
unsafe {
- ffi::ShowWindow(self.window, ffi::SW_HIDE);
+ winapi::ShowWindow(self.window, winapi::SW_HIDE);
}
}
@@ -110,10 +112,10 @@ impl Window {
pub fn get_position(&self) -> Option<(int, int)> {
use std::mem;
- let mut placement: ffi::WINDOWPLACEMENT = unsafe { mem::zeroed() };
- placement.length = mem::size_of::<ffi::WINDOWPLACEMENT>() as ffi::UINT;
+ let mut placement: winapi::WINDOWPLACEMENT = unsafe { mem::zeroed() };
+ placement.length = mem::size_of::<winapi::WINDOWPLACEMENT>() as winapi::UINT;
- if unsafe { ffi::GetWindowPlacement(self.window, &mut placement) } == 0 {
+ if unsafe { winapi::GetWindowPlacement(self.window, &mut placement) } == 0 {
return None
}
@@ -126,18 +128,18 @@ impl Window {
use libc;
unsafe {
- ffi::SetWindowPos(self.window, ptr::null(), x as libc::c_int, y as libc::c_int,
- 0, 0, ffi::SWP_NOZORDER | ffi::SWP_NOSIZE);
- ffi::UpdateWindow(self.window);
+ winapi::SetWindowPos(self.window, ptr::null_mut(), x as libc::c_int, y as libc::c_int,
+ 0, 0, winapi::SWP_NOZORDER | winapi::SWP_NOSIZE);
+ winapi::UpdateWindow(self.window);
}
}
/// See the docs in the crate root file.
pub fn get_inner_size(&self) -> Option<(uint, uint)> {
use std::mem;
- let mut rect: ffi::RECT = unsafe { mem::uninitialized() };
+ let mut rect: winapi::RECT = unsafe { mem::uninitialized() };
- if unsafe { ffi::GetClientRect(self.window, &mut rect) } == 0 {
+ if unsafe { winapi::GetClientRect(self.window, &mut rect) } == 0 {
return None
}
@@ -150,9 +152,9 @@ impl Window {
/// See the docs in the crate root file.
pub fn get_outer_size(&self) -> Option<(uint, uint)> {
use std::mem;
- let mut rect: ffi::RECT = unsafe { mem::uninitialized() };
+ let mut rect: winapi::RECT = unsafe { mem::uninitialized() };
- if unsafe { ffi::GetWindowRect(self.window, &mut rect) } == 0 {
+ if unsafe { winapi::GetWindowRect(self.window, &mut rect) } == 0 {
return None
}
@@ -167,9 +169,9 @@ impl Window {
use libc;
unsafe {
- ffi::SetWindowPos(self.window, ptr::null(), 0, 0, x as libc::c_int,
- y as libc::c_int, ffi::SWP_NOZORDER | ffi::SWP_NOREPOSITION);
- ffi::UpdateWindow(self.window);
+ winapi::SetWindowPos(self.window, ptr::null_mut(), 0, 0, x as libc::c_int,
+ y as libc::c_int, winapi::SWP_NOZORDER | winapi::SWP_NOREPOSITION);
+ winapi::UpdateWindow(self.window);
}
}
@@ -224,7 +226,7 @@ impl Window {
/// See the docs in the crate root file.
pub unsafe fn make_current(&self) {
// TODO: check return value
- ffi::wgl::MakeCurrent(self.hdc, self.context);
+ gl::wgl::MakeCurrent(self.hdc as *const libc::c_void, self.context as *const libc::c_void);
}
/// See the docs in the crate root file.
@@ -233,9 +235,9 @@ impl Window {
unsafe {
addr.with_c_str(|s| {
- let p = ffi::wgl::GetProcAddress(s) as *const ();
+ let p = gl::wgl::GetProcAddress(s) as *const ();
if !p.is_null() { return p; }
- ffi::GetProcAddress(self.gl_library, s) as *const ()
+ winapi::GetProcAddress(self.gl_library, s) as *const ()
})
}
}
@@ -243,7 +245,7 @@ impl Window {
/// See the docs in the crate root file.
pub fn swap_buffers(&self) {
unsafe {
- ffi::SwapBuffers(self.hdc);
+ winapi::SwapBuffers(self.hdc);
}
}
@@ -256,9 +258,9 @@ impl Window {
impl Drop for Window {
fn drop(&mut self) {
use std::ptr;
- unsafe { ffi::PostMessageW(self.window, ffi::WM_DESTROY, 0, 0); }
- unsafe { ffi::wgl::MakeCurrent(ptr::null(), ptr::null()); }
- unsafe { ffi::wgl::DeleteContext(self.context); }
- unsafe { ffi::DestroyWindow(self.window); }
+ unsafe { winapi::PostMessageW(self.window, winapi::WM_DESTROY, 0, 0); }
+ unsafe { gl::wgl::MakeCurrent(ptr::null(), ptr::null()); }
+ unsafe { gl::wgl::DeleteContext(self.context as *const libc::c_void); }
+ unsafe { winapi::DestroyWindow(self.window); }
}
}
diff --git a/src/win32/monitor.rs b/src/win32/monitor.rs
index 3e6b79a..f841f1e 100644
--- a/src/win32/monitor.rs
+++ b/src/win32/monitor.rs
@@ -1,16 +1,16 @@
-use super::ffi;
+use winapi;
/// Win32 implementation of the main `MonitorID` object.
pub struct MonitorID {
/// The system name of the monitor.
- name: [ffi::WCHAR, ..32],
+ name: [winapi::WCHAR, ..32],
/// Name to give to the user.
readable_name: String,
/// See the `StateFlags` element here:
/// http://msdn.microsoft.com/en-us/library/dd183569(v=vs.85).aspx
- flags: ffi::DWORD,
+ flags: winapi::DWORD,
/// The position of the monitor in pixels on the desktop.
///
@@ -33,18 +33,18 @@ pub fn get_available_monitors() -> Vec<MonitorID> {
for id in iter::count(0u, 1) {
// getting the DISPLAY_DEVICEW object of the current device
let output = {
- let mut output: ffi::DISPLAY_DEVICEW = unsafe { mem::zeroed() };
- output.cb = mem::size_of::<ffi::DISPLAY_DEVICEW>() as ffi::DWORD;
+ let mut output: winapi::DISPLAY_DEVICEW = unsafe { mem::zeroed() };
+ output.cb = mem::size_of::<winapi::DISPLAY_DEVICEW>() as winapi::DWORD;
- if unsafe { ffi::EnumDisplayDevicesW(ptr::null(),
- id as ffi::DWORD, &mut output, 0) } == 0
+ if unsafe { winapi::EnumDisplayDevicesW(ptr::null(),
+ id as winapi::DWORD, &mut output, 0) } == 0
{
// the device doesn't exist, which means we have finished enumerating
break;
}
- if (output.StateFlags & ffi::DISPLAY_DEVICE_ACTIVE) == 0 ||
- (output.StateFlags & ffi::DISPLAY_DEVICE_MIRRORING_DRIVER) != 0
+ if (output.StateFlags & winapi::DISPLAY_DEVICE_ACTIVE) == 0 ||
+ (output.StateFlags & winapi::DISPLAY_DEVICE_MIRRORING_DRIVER) != 0
{
// the device is not active
// the Win32 api usually returns a lot of inactive devices
@@ -60,16 +60,16 @@ pub fn get_available_monitors() -> Vec<MonitorID> {
// getting the position
let (position, dimensions) = unsafe {
- let mut dev: ffi::DEVMODE = mem::zeroed();
- dev.dmSize = mem::size_of::<ffi::DEVMODE>() as ffi::WORD;
+ let mut dev: winapi::DEVMODEW = mem::zeroed();
+ dev.dmSize = mem::size_of::<winapi::DEVMODEW>() as winapi::WORD;
- if ffi::EnumDisplaySettingsExW(output.DeviceName.as_ptr(), ffi::ENUM_CURRENT_SETTINGS,
+ if winapi::EnumDisplaySettingsExW(output.DeviceName.as_ptr(), winapi::ENUM_CURRENT_SETTINGS,
&mut dev, 0) == 0
{
continue;
}
- let point: &ffi::POINTL = mem::transmute(&dev.union1);
+ let point: &winapi::POINTL = mem::transmute(&dev.union1);
let position = (point.x as uint, point.y as uint);
let dimensions = (dev.dmPelsWidth as uint, dev.dmPelsHeight as uint);
@@ -96,7 +96,7 @@ pub fn get_primary_monitor() -> MonitorID {
// TODO: it is possible to query the win32 API for the primary monitor, this should be done
// instead
for monitor in get_available_monitors().into_iter() {
- if (monitor.flags & ffi::DISPLAY_DEVICE_PRIMARY_DEVICE) != 0 {
+ if (monitor.flags & winapi::DISPLAY_DEVICE_PRIMARY_DEVICE) != 0 {
return monitor
}
}
@@ -117,7 +117,7 @@ impl MonitorID {
}
/// This is a Win32-only function for `MonitorID` that returns the system name of the device.
- pub fn get_system_name(&self) -> &[ffi::WCHAR] {
+ pub fn get_system_name(&self) -> &[winapi::WCHAR] {
// TODO: retreive the position every time this is called
self.name.as_slice()
}