mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2025-01-11 13:31:29 +11:00
Windows: Fix window.set_maximized() (#672)
* Windows: Fix window.set_maximized() * Add window.set_maximized fix to CHANGELOG. * Windows: use same style for set_maximized as other set_x(bool) methods
This commit is contained in:
parent
50008dff3d
commit
5d5fcb3911
|
@ -11,6 +11,7 @@
|
|||
- Added `WindowBuilderExt::with_gtk_theme_variant` to X11-specific `WindowBuilder` functions.
|
||||
- Fixed UTF8 handling bug in X11 `set_title` function.
|
||||
- On Windows, `Window::set_cursor` now applies immediately instead of requiring specific events to occur first.
|
||||
- On Windows, fix window.set_maximized().
|
||||
|
||||
# Version 0.17.2 (2018-08-19)
|
||||
|
||||
|
|
|
@ -453,25 +453,24 @@ impl Window {
|
|||
#[inline]
|
||||
pub fn set_maximized(&self, maximized: bool) {
|
||||
let mut window_state = self.window_state.lock().unwrap();
|
||||
window_state.maximized = true;
|
||||
// We only maximize if we're not in fullscreen.
|
||||
if window_state.fullscreen.is_none() {
|
||||
return;
|
||||
}
|
||||
|
||||
let window = self.window.clone();
|
||||
unsafe {
|
||||
// `ShowWindow` resizes the window, so it must be called from the main thread.
|
||||
self.events_loop_proxy.execute_in_thread(move |_| {
|
||||
winuser::ShowWindow(
|
||||
window.0,
|
||||
if maximized {
|
||||
winuser::SW_MAXIMIZE
|
||||
} else {
|
||||
winuser::SW_RESTORE
|
||||
},
|
||||
);
|
||||
});
|
||||
if mem::replace(&mut window_state.maximized, maximized) != maximized {
|
||||
// We only maximize if we're not in fullscreen.
|
||||
if window_state.fullscreen.is_none() {
|
||||
let window = self.window.clone();
|
||||
unsafe {
|
||||
// `ShowWindow` resizes the window, so it must be called from the main thread.
|
||||
self.events_loop_proxy.execute_in_thread(move |_| {
|
||||
winuser::ShowWindow(
|
||||
window.0,
|
||||
if maximized {
|
||||
winuser::SW_MAXIMIZE
|
||||
} else {
|
||||
winuser::SW_RESTORE
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue