From 97218046a1d7ad214534173fa3ec2740c396f0d6 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Mon, 8 Jun 2026 18:35:25 +0800 Subject: [PATCH 1/4] Add early return after setting SystemLanguageCode Ensure method exits immediately after finding a matching language code to prevent unnecessary checks and potential overwriting of SystemLanguageCode. --- Flow.Launcher.Core/Resource/Internationalization.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Flow.Launcher.Core/Resource/Internationalization.cs b/Flow.Launcher.Core/Resource/Internationalization.cs index c13fb5c0be7..48543c9c6f2 100644 --- a/Flow.Launcher.Core/Resource/Internationalization.cs +++ b/Flow.Launcher.Core/Resource/Internationalization.cs @@ -59,6 +59,7 @@ public static void InitSystemLanguageCode() string.Equals(languageCode, fullName, StringComparison.OrdinalIgnoreCase)) { SystemLanguageCode = languageCode; + return; } } From 0e2ced9f9bc76ca8625caa3f0e49844b5305e433 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Mon, 8 Jun 2026 18:46:07 +0800 Subject: [PATCH 2/4] Add null checks for window handles and monitor info Improved robustness in Win32Helper.cs by adding null checks for hWndDesktop and monitorInfo. The method now returns false early if either is null, preventing potential null reference errors. --- Flow.Launcher.Infrastructure/Win32Helper.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Flow.Launcher.Infrastructure/Win32Helper.cs b/Flow.Launcher.Infrastructure/Win32Helper.cs index feafcfcdaa0..0087f79cbb4 100644 --- a/Flow.Launcher.Infrastructure/Win32Helper.cs +++ b/Flow.Launcher.Infrastructure/Win32Helper.cs @@ -296,6 +296,10 @@ public static unsafe bool IsForegroundWindowFullscreen() if (windowClass is WINDOW_CLASS_PROGMAN or WINDOW_CLASS_WORKERW) { var hWndDesktop = PInvoke.FindWindowEx(hWnd, HWND.Null, "SHELLDLL_DefView", null); + if (hWndDesktop == HWND.Null) + { + return false; + } hWndDesktop = PInvoke.FindWindowEx(hWndDesktop, HWND.Null, "SysListView32", "FolderView"); if (hWndDesktop != HWND.Null) { @@ -304,6 +308,10 @@ public static unsafe bool IsForegroundWindowFullscreen() } var monitorInfo = MonitorInfo.GetNearestDisplayMonitor(hWnd); + if (monitorInfo == null) + { + return false; + } return (appBounds.bottom - appBounds.top) == monitorInfo.Bounds.Height && (appBounds.right - appBounds.left) == monitorInfo.Bounds.Width; } From b0c794465cccd84a03781b1242d0739f4257654a Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Mon, 8 Jun 2026 18:53:55 +0800 Subject: [PATCH 3/4] Refactor desktop window class child check logic Streamline the process for checking "Progman" and "WorkerW" window classes by only searching for "SysListView32" if "SHELLDLL_DefView" is found. This avoids unnecessary early returns and clarifies the intent of the window hierarchy checks. --- Flow.Launcher.Infrastructure/Win32Helper.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Flow.Launcher.Infrastructure/Win32Helper.cs b/Flow.Launcher.Infrastructure/Win32Helper.cs index 0087f79cbb4..62aa538037c 100644 --- a/Flow.Launcher.Infrastructure/Win32Helper.cs +++ b/Flow.Launcher.Infrastructure/Win32Helper.cs @@ -296,14 +296,13 @@ public static unsafe bool IsForegroundWindowFullscreen() if (windowClass is WINDOW_CLASS_PROGMAN or WINDOW_CLASS_WORKERW) { var hWndDesktop = PInvoke.FindWindowEx(hWnd, HWND.Null, "SHELLDLL_DefView", null); - if (hWndDesktop == HWND.Null) - { - return false; - } - hWndDesktop = PInvoke.FindWindowEx(hWndDesktop, HWND.Null, "SysListView32", "FolderView"); if (hWndDesktop != HWND.Null) { - return false; + hWndDesktop = PInvoke.FindWindowEx(hWndDesktop, HWND.Null, "SysListView32", "FolderView"); + if (hWndDesktop != HWND.Null) + { + return false; + } } } From 82a37427603af7ec1b268e0c7a84d8284e553a3a Mon Sep 17 00:00:00 2001 From: David Brett Date: Mon, 8 Jun 2026 16:43:27 +0200 Subject: [PATCH 4/4] Improve comments and variable naming for desktop check in IsForegroundWindowFullscreen --- Flow.Launcher.Infrastructure/Win32Helper.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Flow.Launcher.Infrastructure/Win32Helper.cs b/Flow.Launcher.Infrastructure/Win32Helper.cs index 62aa538037c..8993caf5266 100644 --- a/Flow.Launcher.Infrastructure/Win32Helper.cs +++ b/Flow.Launcher.Infrastructure/Win32Helper.cs @@ -292,14 +292,16 @@ public static unsafe bool IsForegroundWindowFullscreen() return appBounds.top < 0 && appBounds.bottom < 0; } - // For desktop (Progman or WorkerW, depends on the system), we have to check + // For desktop (Progman or WorkerW, depends on the system), + // we have to check for this hierarchy: + // Progman/WorkerW -> SHELLDLL_DefView -> SysListView32("FolderView") if (windowClass is WINDOW_CLASS_PROGMAN or WINDOW_CLASS_WORKERW) { - var hWndDesktop = PInvoke.FindWindowEx(hWnd, HWND.Null, "SHELLDLL_DefView", null); - if (hWndDesktop != HWND.Null) + var hWndDefView = PInvoke.FindWindowEx(hWnd, HWND.Null, "SHELLDLL_DefView", null); + if (hWndDefView != HWND.Null) { - hWndDesktop = PInvoke.FindWindowEx(hWndDesktop, HWND.Null, "SysListView32", "FolderView"); - if (hWndDesktop != HWND.Null) + var hWndFolderView = PInvoke.FindWindowEx(hWndDefView, HWND.Null, "SysListView32", "FolderView"); + if (hWndFolderView != HWND.Null) { return false; }