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
2 changed files with 12 additions and 1 deletions
|
|
@ -40,7 +40,7 @@ use windows_sys::Win32::{
|
|||
},
|
||||
WindowsAndMessaging::{
|
||||
CreateWindowExW, FlashWindowEx, GetClientRect, GetCursorPos, GetForegroundWindow,
|
||||
GetSystemMetrics, GetWindowPlacement, GetWindowTextLengthW, GetWindowTextW,
|
||||
GetSystemMetrics, GetWindowPlacement, GetWindowTextLengthW, GetWindowTextW, IsIconic,
|
||||
IsWindowVisible, LoadCursorW, PeekMessageW, PostMessageW, RegisterClassExW, SetCursor,
|
||||
SetCursorPos, SetForegroundWindow, SetWindowDisplayAffinity, SetWindowPlacement,
|
||||
SetWindowPos, SetWindowTextW, CS_HREDRAW, CS_VREDRAW, CW_USEDEFAULT, FLASHWINFO,
|
||||
|
|
@ -462,8 +462,13 @@ impl Window {
|
|||
let window = self.window.clone();
|
||||
let window_state = Arc::clone(&self.window_state);
|
||||
|
||||
let is_minimized = self.is_minimized();
|
||||
|
||||
self.thread_executor.execute_in_thread(move || {
|
||||
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| {
|
||||
f.set(WindowFlags::MINIMIZED, minimized)
|
||||
});
|
||||
|
|
@ -489,6 +494,11 @@ impl Window {
|
|||
window_state.window_flags.contains(WindowFlags::MAXIMIZED)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_minimized(&self) -> bool {
|
||||
unsafe { IsIconic(self.hwnd()) == 1 }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn fullscreen(&self) -> Option<Fullscreen> {
|
||||
let window_state = self.window_state_lock();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue