From 1bd483c1590433e7d74371e6d57dd32ced9a3b8b Mon Sep 17 00:00:00 2001 From: David Rickard Date: Sat, 8 Apr 2023 15:42:08 -0700 Subject: [PATCH] fux: avoid running the focus hack if the first focus attempt succeedes (#722) * Avoid running the focus hack code if the first attempt to set the foreground window succeeded. * Added .change file * Accepted PR suggestion * Delete windows-set-foreground-short-circuit.md --- src/platform_impl/windows/window.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/platform_impl/windows/window.rs b/src/platform_impl/windows/window.rs index 7cc6b3c52..c88b18b52 100644 --- a/src/platform_impl/windows/window.rs +++ b/src/platform_impl/windows/window.rs @@ -1267,7 +1267,9 @@ unsafe fn taskbar_mark_fullscreen(handle: HWND, fullscreen: bool) { unsafe fn force_window_active(handle: HWND) { // Try to focus the window without the hack first. - SetForegroundWindow(handle); + if SetForegroundWindow(handle).as_bool() { + return; + } // In some situations, calling SetForegroundWindow could not bring up the window, // This is a little hack which can "steal" the foreground window permission.