Windows & X11: Window::set_resizable (#558)
* Windows: Window::set_resizable * X11: Window::set_resizable * Code style regarding resizable * X11: set_resizable remember max/min window size * Stub out set_resizable on Android, iOS, and emscripten * remove comment block from docs * Windows: set_resizable in fullscreen * Special case Xfwm * Added fun provisos to docs
This commit is contained in:
parent
2b4b64f499
commit
be5a2b0e87
11 changed files with 155 additions and 26 deletions
|
|
@ -239,6 +239,36 @@ impl Window {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_resizable(&self, resizable: bool) {
|
||||
if let Ok(mut window_state) = self.window_state.lock() {
|
||||
if window_state.attributes.resizable == resizable {
|
||||
return;
|
||||
}
|
||||
if window_state.attributes.fullscreen.is_some() {
|
||||
window_state.attributes.resizable = resizable;
|
||||
return;
|
||||
}
|
||||
let window = self.window.clone();
|
||||
let mut style = unsafe {
|
||||
winuser::GetWindowLongW(self.window.0, winuser::GWL_STYLE)
|
||||
};
|
||||
if resizable {
|
||||
style |= winuser::WS_SIZEBOX as LONG;
|
||||
} else {
|
||||
style &= !winuser::WS_SIZEBOX as LONG;
|
||||
}
|
||||
unsafe {
|
||||
winuser::SetWindowLongW(
|
||||
window.0,
|
||||
winuser::GWL_STYLE,
|
||||
style as _,
|
||||
);
|
||||
};
|
||||
window_state.attributes.resizable = resizable;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: remove
|
||||
pub fn platform_display(&self) -> *mut ::libc::c_void {
|
||||
|
|
@ -478,14 +508,20 @@ impl Window {
|
|||
|
||||
let rect = saved_window_info.rect.clone();
|
||||
let window = self.window.clone();
|
||||
let (style, ex_style) = (saved_window_info.style, saved_window_info.ex_style);
|
||||
let (mut style, ex_style) = (saved_window_info.style, saved_window_info.ex_style);
|
||||
|
||||
let maximized = window_state.attributes.maximized;
|
||||
let resizable = window_state.attributes.resizable;
|
||||
|
||||
// On restore, resize to the previous saved rect size.
|
||||
// And because SetWindowPos will resize the window
|
||||
// We call it in the main thread
|
||||
self.events_loop_proxy.execute_in_thread(move |_| {
|
||||
if resizable {
|
||||
style |= winuser::WS_SIZEBOX as LONG;
|
||||
} else {
|
||||
style &= !winuser::WS_SIZEBOX as LONG;
|
||||
}
|
||||
winuser::SetWindowLongW(window.0, winuser::GWL_STYLE, style);
|
||||
winuser::SetWindowLongW(window.0, winuser::GWL_EXSTYLE, ex_style);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue