From b7dab732a9b8c71e7433c8f1b69e55c9c49f4e50 Mon Sep 17 00:00:00 2001 From: muwoo <2424880409@qq.com> Date: Fri, 28 Jun 2024 11:00:30 +0800 Subject: [PATCH] fix(windows): `Window::request_user_attention` not taking effect after minimizing the window by clicking the taskbar icon (#947) --- .changes/fix-user-attention-minimized.md | 5 +++++ src/platform_impl/windows/window.rs | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 .changes/fix-user-attention-minimized.md diff --git a/.changes/fix-user-attention-minimized.md b/.changes/fix-user-attention-minimized.md new file mode 100644 index 000000000..f76fd123f --- /dev/null +++ b/.changes/fix-user-attention-minimized.md @@ -0,0 +1,5 @@ +--- +"tao": patch +--- + +Fix `Window::request_user_attention` not taking effect after minimizing the window by clicking the taskbar icon diff --git a/src/platform_impl/windows/window.rs b/src/platform_impl/windows/window.rs index 3b4b328ea..bc792606c 100644 --- a/src/platform_impl/windows/window.rs +++ b/src/platform_impl/windows/window.rs @@ -876,7 +876,13 @@ impl Window { let window = self.window.clone(); let active_window_handle = unsafe { GetActiveWindow() }; if window.0 == active_window_handle { - return; + // active window could be minimized, so we skip requesting attention + // if it is not minimized + let window_flags = self.window_state.lock().window_flags(); + let is_minimized = window_flags.contains(WindowFlags::MINIMIZED); + if !is_minimized { + return; + } } self.thread_executor.execute_in_thread(move || unsafe {