diff options
author | tomaka <pierre.krieger1708@gmail.com> | 2015-12-05 18:01:55 +0100 |
---|---|---|
committer | tomaka <pierre.krieger1708@gmail.com> | 2015-12-05 18:01:55 +0100 |
commit | 48a02a0c8c9029543360884f1daaaade5d3f11a5 (patch) | |
tree | 0489869b1f75bbd9571e01c39a2d35427c984102 /src/api/win32/callback.rs | |
parent | 8c3ffd2a4fe2dbb0033c1f830d384c0c2d8c88a1 (diff) | |
parent | 2be3c142f0778a3588982572a997dc669adca2a6 (diff) | |
download | glutin-48a02a0c8c9029543360884f1daaaade5d3f11a5.tar.gz glutin-48a02a0c8c9029543360884f1daaaade5d3f11a5.zip |
Merge pull request #659 from Aceeri/minmaxwindow
Minimum/maximum dimensions for windows in win32 API
Diffstat (limited to 'src/api/win32/callback.rs')
-rw-r--r-- | src/api/win32/callback.rs | 46 |
1 files changed, 43 insertions, 3 deletions
diff --git a/src/api/win32/callback.rs b/src/api/win32/callback.rs index 45de907..5cd8ade 100644 --- a/src/api/win32/callback.rs +++ b/src/api/win32/callback.rs @@ -6,9 +6,11 @@ use std::sync::{Arc, Mutex}; use std::ffi::OsString; use std::os::windows::ffi::OsStringExt; +use WindowAttributes; use CursorState; use Event; use super::event; +use super::WindowState; use user32; use shell32; @@ -22,7 +24,15 @@ thread_local!(pub static CONTEXT_STASH: RefCell<Option<ThreadLocalData>> = RefCe pub struct ThreadLocalData { pub win: winapi::HWND, pub sender: Sender<Event>, - pub cursor_state: Arc<Mutex<CursorState>> + pub window_state: Arc<Mutex<WindowState>> +} + +struct MinMaxInfo { + reserved: winapi::POINT, // Do not use/change + max_size: winapi::POINT, + max_position: winapi::POINT, + min_track: winapi::POINT, + max_track: winapi::POINT } /// Checks that the window is the good one, and if so send the event to it. @@ -241,8 +251,8 @@ pub unsafe extern "system" fn callback(window: winapi::HWND, msg: winapi::UINT, // there's a very bizarre borrow checker bug // possibly related to rust-lang/rust/#23338 let _cursor_state = if let Some(cstash) = cstash { - if let Ok(cursor_state) = cstash.cursor_state.lock() { - match *cursor_state { + if let Ok(window_state) = cstash.window_state.lock() { + match window_state.cursor_state { CursorState::Normal => { user32::SetCursor(user32::LoadCursorW( ptr::null_mut(), @@ -281,6 +291,36 @@ pub unsafe extern "system" fn callback(window: winapi::HWND, msg: winapi::UINT, 0 }, + winapi::WM_GETMINMAXINFO => { + let mut mmi = lparam as *mut MinMaxInfo; + //(*mmi).max_position = winapi::POINT { x: -8, y: -8 }; // The upper left corner of the window if it were maximized on the primary monitor. + //(*mmi).max_size = winapi::POINT { x: .., y: .. }; // The dimensions of the primary monitor. + + CONTEXT_STASH.with(|context_stash| { + match context_stash.borrow().as_ref() { + Some(cstash) => { + let window_state = cstash.window_state.lock().unwrap(); + + match window_state.attributes.min_dimensions { + Some((width, height)) => { + (*mmi).min_track = winapi::POINT { x: width as i32, y: height as i32 }; + }, + None => { } + } + + match window_state.attributes.max_dimensions { + Some((width, height)) => { + (*mmi).max_track = winapi::POINT { x: width as i32, y: height as i32 }; + }, + None => { } + } + }, + None => { } + } + }); + 0 + }, + x if x == *super::WAKEUP_MSG_ID => { use events::Event::Awakened; send_event(window, Awakened); |