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.
This commit is contained in:
Jack251970 2026-03-01 14:16:36 +08:00
parent 428a7ad0c2
commit 4767b444ec

View file

@ -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;
}
}
}