aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMathijs van de Nes <git@mathijs.vd-nes.nl>2015-09-23 13:11:00 +0200
committerMathijs van de Nes <git@mathijs.vd-nes.nl>2015-09-23 13:11:00 +0200
commit4046a892ee5d8e7ac3b3a4e42d8692e878dceb7f (patch)
tree830fcef630623118b3cb13f6e467857db70d8121
parent0f9693bde4d67e77fa3691a2c9d3ed0151abec71 (diff)
downloadglutin-4046a892ee5d8e7ac3b3a4e42d8692e878dceb7f.tar.gz
glutin-4046a892ee5d8e7ac3b3a4e42d8692e878dceb7f.zip
Fix Window.set_inner_size() on Win32
Previously, the function would actually set the outer size of the window instead of the inner size. We fix this by first letting windows calculate the outer size based upon the specified inner size.
-rw-r--r--src/api/win32/mod.rs13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/api/win32/mod.rs b/src/api/win32/mod.rs
index f580950..59fdf5d 100644
--- a/src/api/win32/mod.rs
+++ b/src/api/win32/mod.rs
@@ -182,8 +182,17 @@ impl Window {
use libc;
unsafe {
- user32::SetWindowPos(self.window.0, ptr::null_mut(), 0, 0, x as libc::c_int,
- y as libc::c_int, winapi::SWP_NOZORDER | winapi::SWP_NOREPOSITION | winapi::SWP_NOMOVE);
+ // Calculate the outer size based upon the specified inner size
+ let mut rect = winapi::RECT { top: 0, left: 0, bottom: y as winapi::LONG, right: x as winapi::LONG };
+ let dw_style = user32::GetWindowLongA(self.window.0, winapi::GWL_STYLE) as winapi::DWORD;
+ let b_menu = !user32::GetMenu(self.window.0).is_null() as winapi::BOOL;
+ let dw_style_ex = user32::GetWindowLongA(self.window.0, winapi::GWL_EXSTYLE) as winapi::DWORD;
+ user32::AdjustWindowRectEx(&mut rect, dw_style, b_menu, dw_style_ex);
+ let outer_x = (rect.right - rect.left).abs() as libc::c_int;
+ let outer_y = (rect.top - rect.bottom).abs() as libc::c_int;
+
+ user32::SetWindowPos(self.window.0, ptr::null_mut(), 0, 0, outer_x, outer_y,
+ winapi::SWP_NOZORDER | winapi::SWP_NOREPOSITION | winapi::SWP_NOMOVE);
user32::UpdateWindow(self.window.0);
}
}