From 633d3b47e55a317d66850f0a6f24cad7c5b935ce Mon Sep 17 00:00:00 2001 From: David Brett Date: Sat, 6 Jun 2026 12:50:48 +0200 Subject: [PATCH 1/6] Only subtract shadow margin when an effect is present during RemoveDropShadowEffectFromCurrentTheme --- Flow.Launcher.Core/Resource/Theme.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Flow.Launcher.Core/Resource/Theme.cs b/Flow.Launcher.Core/Resource/Theme.cs index ed9677cff2c..8b3d76eb8df 100644 --- a/Flow.Launcher.Core/Resource/Theme.cs +++ b/Flow.Launcher.Core/Resource/Theme.cs @@ -554,6 +554,11 @@ public void RemoveDropShadowEffectFromCurrentTheme() ThemeHelper.CopyStyle(windowBorderStyle, newWindowBorderStyle); // Copy Setters, excluding the Effect setter and updating the Margin setter + // Only adjust margin if there's actually a shadow effect to remove, + // preventing it from shrinking on repeated calls. + bool hasEffect = windowBorderStyle.Setters.OfType() + .Any(s => s.Property == UIElement.EffectProperty); + foreach (var setterBase in windowBorderStyle.Setters) { if (setterBase is Setter setter) @@ -562,7 +567,7 @@ public void RemoveDropShadowEffectFromCurrentTheme() if (setter.Property == UIElement.EffectProperty) continue; // Update Margin by subtracting the extra margin we added for the shadow - if (setter.Property == FrameworkElement.MarginProperty) + if (hasEffect && setter.Property == FrameworkElement.MarginProperty) { var currentMargin = (Thickness)setter.Value; var newMargin = new Thickness( From a88815fd37a7bd3e073009cbbdb8b91868bd5647 Mon Sep 17 00:00:00 2001 From: David Brett Date: Sat, 6 Jun 2026 12:52:35 +0200 Subject: [PATCH 2/6] Skip RemoveDropShadowEffectFromCurrentTheme for blur themes The method was loading raw theme XAML and directly setting WindowBorderStyle, always overriding SetBlurForWindow's transparent background and CornerRadius=0 Should fix #4457 --- Flow.Launcher.Core/Resource/Theme.cs | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/Flow.Launcher.Core/Resource/Theme.cs b/Flow.Launcher.Core/Resource/Theme.cs index 8b3d76eb8df..c413d3ab76c 100644 --- a/Flow.Launcher.Core/Resource/Theme.cs +++ b/Flow.Launcher.Core/Resource/Theme.cs @@ -643,17 +643,8 @@ await Application.Current.Dispatcher.InvokeAsync(() => // Remove OS minimizing/maximizing animation // Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_TRANSITIONS_FORCEDISABLED, 3); - // The timing of adding the shadow effect should vary depending on whether the theme is transparent. - if (BlurEnabled) - { - AutoDropShadow(useDropShadowEffect); - } SetBlurForWindow(_settings.Theme, backdropType); - - if (!BlurEnabled) - { - AutoDropShadow(useDropShadowEffect); - } + AutoDropShadow(useDropShadowEffect); }, DispatcherPriority.Render); } @@ -747,10 +738,11 @@ private void AutoDropShadow(bool useDropShadowEffect) { if (BlurEnabled && Win32Helper.IsBackdropSupported()) { - // For themes with blur enabled, the window border is rendered by the system, - // so we set corner preference to round and remove drop shadow effect to avoid rendering issues. + // Blur themes: DWM handles corners. Clear any stale directly-set + // resource so the merged dictionary entry (from SetBlurForWindow) wins. SetWindowCornerPreference("Round"); - RemoveDropShadowEffectFromCurrentTheme(); + if (Application.Current.Resources.Contains("WindowBorderStyle")) + Application.Current.Resources.Remove("WindowBorderStyle"); } else { From 8507daf592ccd62ee47091d070f95ca6420e9ded Mon Sep 17 00:00:00 2001 From: David Brett Date: Sat, 6 Jun 2026 13:12:08 +0200 Subject: [PATCH 3/6] Extend DWM frame into client area for backdrop rendering --- Flow.Launcher.Infrastructure/NativeMethods.txt | 1 + Flow.Launcher.Infrastructure/Win32Helper.cs | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/Flow.Launcher.Infrastructure/NativeMethods.txt b/Flow.Launcher.Infrastructure/NativeMethods.txt index 8c5633cfef5..acebfcfe37e 100644 --- a/Flow.Launcher.Infrastructure/NativeMethods.txt +++ b/Flow.Launcher.Infrastructure/NativeMethods.txt @@ -14,6 +14,7 @@ VIRTUAL_KEY EnumWindows DwmSetWindowAttribute +DwmExtendFrameIntoClientArea DWM_SYSTEMBACKDROP_TYPE DWM_WINDOW_CORNER_PREFERENCE diff --git a/Flow.Launcher.Infrastructure/Win32Helper.cs b/Flow.Launcher.Infrastructure/Win32Helper.cs index 67d0edb7888..feafcfcdaa0 100644 --- a/Flow.Launcher.Infrastructure/Win32Helper.cs +++ b/Flow.Launcher.Infrastructure/Win32Helper.cs @@ -21,6 +21,7 @@ using Windows.Win32.Graphics.Dwm; using Windows.Win32.System.Power; using Windows.Win32.System.Threading; +using Windows.Win32.UI.Controls; using Windows.Win32.UI.Input.KeyboardAndMouse; using Windows.Win32.UI.Shell.Common; using Windows.Win32.UI.WindowsAndMessaging; @@ -61,6 +62,14 @@ public static unsafe bool DWMSetBackdropForWindow(Window window, BackdropTypes b _ => DWM_SYSTEMBACKDROP_TYPE.DWMSBT_AUTO }; + // The backdrop renders in the non-client frame area. WindowStyle=None + // removes that area, so we extend it across the entire client area. + // This is harmless when backdrop is None or blur not enabled + // as DWM has nothing to render in the extended area. + // https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/nf-dwmapi-dwmextendframeintoclientarea + var margins = new MARGINS { cxLeftWidth = -1, cxRightWidth = -1, cyTopHeight = -1, cyBottomHeight = -1 }; + PInvoke.DwmExtendFrameIntoClientArea(GetWindowHandle(window), in margins); + return PInvoke.DwmSetWindowAttribute( GetWindowHandle(window), DWMWINDOWATTRIBUTE.DWMWA_SYSTEMBACKDROP_TYPE, From 4232313c1005c8f55038f61255d46c490b86b22e Mon Sep 17 00:00:00 2001 From: David Brett Date: Sat, 6 Jun 2026 16:44:59 +0200 Subject: [PATCH 4/6] Set resize boarder thickness to default when using blur theme --- Flow.Launcher.Core/Resource/Theme.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Flow.Launcher.Core/Resource/Theme.cs b/Flow.Launcher.Core/Resource/Theme.cs index c413d3ab76c..774ee873259 100644 --- a/Flow.Launcher.Core/Resource/Theme.cs +++ b/Flow.Launcher.Core/Resource/Theme.cs @@ -743,6 +743,7 @@ private void AutoDropShadow(bool useDropShadowEffect) SetWindowCornerPreference("Round"); if (Application.Current.Resources.Contains("WindowBorderStyle")) Application.Current.Resources.Remove("WindowBorderStyle"); + SetResizeBoarderThickness(null); } else { From ae93f8b2b08b41873b599048374e67347bb78b20 Mon Sep 17 00:00:00 2001 From: David Brett Date: Sat, 6 Jun 2026 20:15:37 +0200 Subject: [PATCH 5/6] Remove commented-out code in RefreshFrameAsync --- Flow.Launcher.Core/Resource/Theme.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/Flow.Launcher.Core/Resource/Theme.cs b/Flow.Launcher.Core/Resource/Theme.cs index 774ee873259..a1694200b85 100644 --- a/Flow.Launcher.Core/Resource/Theme.cs +++ b/Flow.Launcher.Core/Resource/Theme.cs @@ -640,9 +640,6 @@ await Application.Current.Dispatcher.InvokeAsync(() => // Get the actual backdrop type and drop shadow effect settings var (backdropType, useDropShadowEffect) = GetActualValue(); - // Remove OS minimizing/maximizing animation - // Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_TRANSITIONS_FORCEDISABLED, 3); - SetBlurForWindow(_settings.Theme, backdropType); AutoDropShadow(useDropShadowEffect); }, DispatcherPriority.Render); From 7cf0b9772ba59f9316ede96adaec4ec7928f79c2 Mon Sep 17 00:00:00 2001 From: David Brett Date: Sat, 6 Jun 2026 20:32:56 +0200 Subject: [PATCH 6/6] Move DWM corner preference, WindowBorderStyle removal, and resize border reset from AutoDropShadow to SetBlurForWindow - AutoDropShadow is now simplified to only handle adding or removing the drop shadow effect. - The WindowBorderStyle removal, and resize border reset were just cleanup for SetBlurForWindow so make more sense to be there. - The Corner prefernce was only really a binary choice between blur enabled or not - so SetBlurForWindow can also handle that. --- Flow.Launcher.Core/Resource/Theme.cs | 35 ++++++++++++++-------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/Flow.Launcher.Core/Resource/Theme.cs b/Flow.Launcher.Core/Resource/Theme.cs index a1694200b85..45758a0042b 100644 --- a/Flow.Launcher.Core/Resource/Theme.cs +++ b/Flow.Launcher.Core/Resource/Theme.cs @@ -718,12 +718,26 @@ private void SetBlurForWindow(string theme, BackdropTypes backdropType) // Apply the blur effect Win32Helper.DWMSetBackdropForWindow(mainWindow, backdropType); ColorizeWindow(theme, backdropType); + + // DWM renders rounded corners for backdrop windows + SetWindowCornerPreference("Round"); + + // Clear any stale directly-set WindowBorderStyle that might shadow + // the merged dictionary entry we just modified above. + if (Application.Current.Resources.Contains("WindowBorderStyle")) + Application.Current.Resources.Remove("WindowBorderStyle"); + + // For blur themes the resize border defaults to the system thickness. + SetResizeBoarderThickness(null); } else { // Apply default style when Blur is disabled Win32Helper.DWMSetBackdropForWindow(mainWindow, BackdropTypes.None); ColorizeWindow(theme, backdropType); + + // Non-blur themes use the default window corner preference + SetWindowCornerPreference("Default"); } UpdateResourceDictionary(dict); @@ -731,28 +745,15 @@ private void SetBlurForWindow(string theme, BackdropTypes backdropType) private void AutoDropShadow(bool useDropShadowEffect) { + if (BlurEnabled) + return; // Blur themes have no drop shadow effect + if (useDropShadowEffect) { - if (BlurEnabled && Win32Helper.IsBackdropSupported()) - { - // Blur themes: DWM handles corners. Clear any stale directly-set - // resource so the merged dictionary entry (from SetBlurForWindow) wins. - SetWindowCornerPreference("Round"); - if (Application.Current.Resources.Contains("WindowBorderStyle")) - Application.Current.Resources.Remove("WindowBorderStyle"); - SetResizeBoarderThickness(null); - } - else - { - // For themes without blur, we set corner preference to default and add drop shadow effect. - SetWindowCornerPreference("Default"); - AddDropShadowEffectToCurrentTheme(); - } + AddDropShadowEffectToCurrentTheme(); } else { - // When drop shadow effect is disabled, we set corner preference to default and remove drop shadow effect. - SetWindowCornerPreference("Default"); RemoveDropShadowEffectFromCurrentTheme(); } }