From a4f0b92b4e754427033842a18927096731f6449f Mon Sep 17 00:00:00 2001 From: edde746 <86283021+edde746@users.noreply.github.com> Date: Sat, 30 May 2026 03:00:24 +0200 Subject: [PATCH] fix(windows): stop taskbar icon flashing on minimize after playback --- windows/runner/mpv/mpv_container.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/windows/runner/mpv/mpv_container.cpp b/windows/runner/mpv/mpv_container.cpp index cd4c15a1..25abdb2b 100644 --- a/windows/runner/mpv/mpv_container.cpp +++ b/windows/runner/mpv/mpv_container.cpp @@ -67,7 +67,17 @@ MpvContainer::WindowProc(HWND const window, UINT const message, WPARAM const wpa // Redirect focus to Flutter window. auto user_data = ::GetWindowLongPtr(window, GWLP_USERDATA); if (user_data) { - ::SetForegroundWindow(reinterpret_cast(user_data)); + HWND flutter_window = reinterpret_cast(user_data); + // Don't try to foreground a minimized window (Windows refuses and flashes + // the taskbar button instead), and don't steal foreground from another + // application. Only redirect focus when our own window already owns the + // foreground. + if (!::IsIconic(flutter_window)) { + HWND foreground = ::GetForegroundWindow(); + if (foreground == flutter_window || foreground == window) { + ::SetForegroundWindow(flutter_window); + } + } } break; }