diff --git a/CHANGELOG.md b/CHANGELOG.md index d4695817..203b7000 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ And please only add new entries to the top of this list, right below the `# Unre # 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:** 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. diff --git a/src/platform_impl/windows/window.rs b/src/platform_impl/windows/window.rs index cbf6dadc..7ba8c44a 100644 --- a/src/platform_impl/windows/window.rs +++ b/src/platform_impl/windows/window.rs @@ -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 { let window_state = self.window_state_lock();