From 4767b444ec4c2efc1643dc06ff8c2bd1c65711e2 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Sun, 1 Mar 2026 14:16:36 +0800 Subject: [PATCH] Optimize SolidColorBrush usage for window background Freeze SolidColorBrush instances before assigning them to mainWindow.Background to improve performance and immutability. Applied to both transparent and selected background scenarios. --- Flow.Launcher.Core/Resource/Theme.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Flow.Launcher.Core/Resource/Theme.cs b/Flow.Launcher.Core/Resource/Theme.cs index 099d46780..3a34b867a 100644 --- a/Flow.Launcher.Core/Resource/Theme.cs +++ b/Flow.Launcher.Core/Resource/Theme.cs @@ -1036,11 +1036,15 @@ namespace Flow.Launcher.Core.Resource // Only set the background to transparent if the theme supports blur if (backdropType == BackdropTypes.Mica || backdropType == BackdropTypes.MicaAlt) { - mainWindow.Background = new SolidColorBrush(Color.FromArgb(1, 0, 0, 0)); + var backgroundBrush = new SolidColorBrush(Color.FromArgb(1, 0, 0, 0)); + backgroundBrush.Freeze(); + mainWindow.Background = backgroundBrush; } else { - mainWindow.Background = new SolidColorBrush(selectedBG); + var backgroundBrush = new SolidColorBrush(selectedBG); + backgroundBrush.Freeze(); + mainWindow.Background = backgroundBrush; } } }