aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomaka17 <pierre.krieger1708@gmail.com>2014-07-27 22:36:44 +0200
committerTomaka17 <pierre.krieger1708@gmail.com>2014-07-27 22:36:55 +0200
commit14a697b272ab74058e9aa375851c13c18f07731e (patch)
tree639ac1b59a1fe7a4744597f3e9b70c54bbdaa0a4
parentd4e334aecb1f6d6f85752ddbbf0a2da688036109 (diff)
downloadglutin-14a697b272ab74058e9aa375851c13c18f07731e.tar.gz
glutin-14a697b272ab74058e9aa375851c13c18f07731e.zip
Implement get_*_size() for win32
-rw-r--r--src/win32/ffi.rs6
-rw-r--r--src/win32/mod.rs24
2 files changed, 28 insertions, 2 deletions
diff --git a/src/win32/ffi.rs b/src/win32/ffi.rs
index 4a3ce7e..857b838 100644
--- a/src/win32/ffi.rs
+++ b/src/win32/ffi.rs
@@ -603,6 +603,9 @@ extern "system" {
// 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;
@@ -618,6 +621,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/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;
diff --git a/src/win32/mod.rs b/src/win32/mod.rs
index b5e507b..8f3ae91 100644
--- a/src/win32/mod.rs
+++ b/src/win32/mod.rs
@@ -222,11 +222,31 @@ impl Window {
}
pub fn get_inner_size(&self) -> (uint, uint) {
- unimplemented!()
+ use std::{mem, os};
+ let mut rect: ffi::RECT = unsafe { mem::uninitialized() };
+
+ if unsafe { ffi::GetClientRect(self.window, &mut rect) } == 0 {
+ fail!("GetClientRect failed: {}", os::error_string(os::errno() as uint));
+ }
+
+ (
+ (rect.right - rect.left) as uint,
+ (rect.bottom - rect.top) as uint
+ )
}
pub fn get_outer_size(&self) -> (uint, uint) {
- unimplemented!()
+ use std::{mem, os};
+ let mut rect: ffi::RECT = unsafe { mem::uninitialized() };
+
+ if unsafe { ffi::GetWindowRect(self.window, &mut rect) } == 0 {
+ fail!("GetWindowRect failed: {}", os::error_string(os::errno() as uint));
+ }
+
+ (
+ (rect.right - rect.left) as uint,
+ (rect.bottom - rect.top) as uint
+ )
}
pub fn set_inner_size(&self, x: uint, y: uint) {