mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-23 22:01:31 +11:00
Fix Window::set_minimized(false)
on Windows
When other application minimized the winit window the minimize state was going out of sync. This commit fixes it by polling the state in `set_minimized`.
This commit is contained in:
parent
7d626d9dfd
commit
067535eb38
|
@ -8,6 +8,7 @@ And please only add new entries to the top of this list, right below the `# Unre
|
||||||
|
|
||||||
# Unreleased
|
# Unreleased
|
||||||
|
|
||||||
|
- On Windows, fix `Window::set_minimized(false)` not working for windows minimized by `Win + D` hotkey.
|
||||||
- **Breaking:** On Web, touch input no longer fires `WindowEvent::Cursor*`, `WindowEvent::MouseInput`, or `DeviceEvent::MouseMotion` like other platforms, but instead it fires `WindowEvent::Touch`.
|
- **Breaking:** On Web, touch input no longer fires `WindowEvent::Cursor*`, `WindowEvent::MouseInput`, or `DeviceEvent::MouseMotion` like other platforms, but instead it fires `WindowEvent::Touch`.
|
||||||
- **Breaking:** Removed platform specific `WindowBuilder::with_parent` API in favor of `WindowBuilder::with_parent_window`.
|
- **Breaking:** Removed platform specific `WindowBuilder::with_parent` API in favor of `WindowBuilder::with_parent_window`.
|
||||||
- On Windows, retain `WS_MAXIMIZE` window style when un-minimizing a maximized window.
|
- On Windows, retain `WS_MAXIMIZE` window style when un-minimizing a maximized window.
|
||||||
|
|
|
@ -40,7 +40,7 @@ use windows_sys::Win32::{
|
||||||
},
|
},
|
||||||
WindowsAndMessaging::{
|
WindowsAndMessaging::{
|
||||||
CreateWindowExW, FlashWindowEx, GetClientRect, GetCursorPos, GetForegroundWindow,
|
CreateWindowExW, FlashWindowEx, GetClientRect, GetCursorPos, GetForegroundWindow,
|
||||||
GetSystemMetrics, GetWindowPlacement, GetWindowTextLengthW, GetWindowTextW,
|
GetSystemMetrics, GetWindowPlacement, GetWindowTextLengthW, GetWindowTextW, IsIconic,
|
||||||
IsWindowVisible, LoadCursorW, PeekMessageW, PostMessageW, RegisterClassExW, SetCursor,
|
IsWindowVisible, LoadCursorW, PeekMessageW, PostMessageW, RegisterClassExW, SetCursor,
|
||||||
SetCursorPos, SetForegroundWindow, SetWindowDisplayAffinity, SetWindowPlacement,
|
SetCursorPos, SetForegroundWindow, SetWindowDisplayAffinity, SetWindowPlacement,
|
||||||
SetWindowPos, SetWindowTextW, CS_HREDRAW, CS_VREDRAW, CW_USEDEFAULT, FLASHWINFO,
|
SetWindowPos, SetWindowTextW, CS_HREDRAW, CS_VREDRAW, CW_USEDEFAULT, FLASHWINFO,
|
||||||
|
@ -462,8 +462,13 @@ impl Window {
|
||||||
let window = self.window.clone();
|
let window = self.window.clone();
|
||||||
let window_state = Arc::clone(&self.window_state);
|
let window_state = Arc::clone(&self.window_state);
|
||||||
|
|
||||||
|
let is_minimized = self.is_minimized();
|
||||||
|
|
||||||
self.thread_executor.execute_in_thread(move || {
|
self.thread_executor.execute_in_thread(move || {
|
||||||
let _ = &window;
|
let _ = &window;
|
||||||
|
WindowState::set_window_flags_in_place(&mut window_state.lock().unwrap(), |f| {
|
||||||
|
f.set(WindowFlags::MINIMIZED, is_minimized)
|
||||||
|
});
|
||||||
WindowState::set_window_flags(window_state.lock().unwrap(), window.0, |f| {
|
WindowState::set_window_flags(window_state.lock().unwrap(), window.0, |f| {
|
||||||
f.set(WindowFlags::MINIMIZED, minimized)
|
f.set(WindowFlags::MINIMIZED, minimized)
|
||||||
});
|
});
|
||||||
|
@ -489,6 +494,11 @@ impl Window {
|
||||||
window_state.window_flags.contains(WindowFlags::MAXIMIZED)
|
window_state.window_flags.contains(WindowFlags::MAXIMIZED)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn is_minimized(&self) -> bool {
|
||||||
|
unsafe { IsIconic(self.hwnd()) == 1 }
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn fullscreen(&self) -> Option<Fullscreen> {
|
pub fn fullscreen(&self) -> Option<Fullscreen> {
|
||||||
let window_state = self.window_state_lock();
|
let window_state = self.window_state_lock();
|
||||||
|
|
Loading…
Reference in a new issue