aboutsummaryrefslogtreecommitdiffstats
path: root/src/win32
diff options
context:
space:
mode:
authorTomaka17 <pierre.krieger1708@gmail.com>2014-07-27 22:46:30 +0200
committerTomaka17 <pierre.krieger1708@gmail.com>2014-07-27 22:46:30 +0200
commit1f0999e6a0470826ea5bbde2ba5e17758ef7751a (patch)
tree0e4e368746bc9c2cd3d8b3fa0cad092e99f542bb /src/win32
parent14a697b272ab74058e9aa375851c13c18f07731e (diff)
downloadglutin-1f0999e6a0470826ea5bbde2ba5e17758ef7751a.tar.gz
glutin-1f0999e6a0470826ea5bbde2ba5e17758ef7751a.zip
Implement get_position for win32 and fix interface
Diffstat (limited to 'src/win32')
-rw-r--r--src/win32/ffi.rs14
-rw-r--r--src/win32/mod.rs18
2 files changed, 28 insertions, 4 deletions
diff --git a/src/win32/ffi.rs b/src/win32/ffi.rs
index 857b838..268edbc 100644
--- a/src/win32/ffi.rs
+++ b/src/win32/ffi.rs
@@ -552,6 +552,17 @@ pub struct DEVMODE {
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,
+}
+
pub type LPMSG = *mut MSG;
#[link(name = "advapi32")]
@@ -621,6 +632,9 @@ extern "system" {
// 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;
diff --git a/src/win32/mod.rs b/src/win32/mod.rs
index 8f3ae91..74b046b 100644
--- a/src/win32/mod.rs
+++ b/src/win32/mod.rs
@@ -207,8 +207,18 @@ impl Window {
}
}
- pub fn get_position(&self) -> (uint, uint) {
- unimplemented!()
+ pub fn get_position(&self) -> (int, int) {
+ use std::{mem, os};
+
+ let mut placement: ffi::WINDOWPLACEMENT = unsafe { mem::zeroed() };
+ placement.length = mem::size_of::<ffi::WINDOWPLACEMENT>() as ffi::UINT;
+
+ if unsafe { ffi::GetWindowPlacement(self.window, &mut placement) } == 0 {
+ fail!("GetWindowPlacement failed: {}", os::error_string(os::errno() as uint));
+ }
+
+ let ref rect = placement.rcNormalPosition;
+ (rect.left as int, rect.top as int)
}
pub fn set_position(&self, x: uint, y: uint) {
@@ -363,8 +373,8 @@ extern "stdcall" fn callback(window: ffi::HWND, msg: ffi::UINT,
ffi::WM_MOVE => {
use events::Moved;
- let x = ffi::LOWORD(lparam as ffi::DWORD) as uint;
- let y = ffi::HIWORD(lparam as ffi::DWORD) as uint;
+ let x = ffi::LOWORD(lparam as ffi::DWORD) as i16 as int;
+ let y = ffi::HIWORD(lparam as ffi::DWORD) as i16 as int;
send_event(window, Moved(x, y));
0
},