From 53cb94dc60c50a9f721a4ef23879ab6e63bc3ead Mon Sep 17 00:00:00 2001 From: DB p Date: Mon, 24 Feb 2025 15:16:11 +0900 Subject: [PATCH] Fix first load issue --- Flow.Launcher.Core/Resource/Theme.cs | 10 ++++++++++ Flow.Launcher/MainWindow.xaml.cs | 5 ++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Flow.Launcher.Core/Resource/Theme.cs b/Flow.Launcher.Core/Resource/Theme.cs index 3ebcd65c7..01661678b 100644 --- a/Flow.Launcher.Core/Resource/Theme.cs +++ b/Flow.Launcher.Core/Resource/Theme.cs @@ -108,7 +108,12 @@ namespace Flow.Launcher.Core.Resource public void RefreshFrame() { IntPtr mainWindowPtr = new WindowInteropHelper(mainWindow).Handle; + if (mainWindowPtr == IntPtr.Zero) + return; + HwndSource mainWindowSrc = HwndSource.FromHwnd(mainWindowPtr); + if (mainWindowSrc == null) + return; //mainWindowSrc.CompositionTarget.BackgroundColor = Color.FromArgb(0, 255, 181, 178); ParameterTypes.MARGINS margins = new ParameterTypes.MARGINS(); @@ -136,7 +141,12 @@ namespace Flow.Launcher.Core.Resource //SetWindowAccent(); var dict = GetThemeResourceDictionary(Settings.Theme); + if (dict == null) + return; + var windowBorderStyle = dict["WindowBorderStyle"] as Style; + if (windowBorderStyle == null) + return; Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_SYSTEMBACKDROP_TYPE, 3); if (BlurEnabled) { diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index 8270150c2..264f57cb5 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -181,7 +181,10 @@ namespace Flow.Launcher private void OnLoaded(object sender, RoutedEventArgs _) { - ThemeManager.Instance.RefreshFrame(); + Dispatcher.BeginInvoke((Action)(() => + { + ThemeManager.Instance.RefreshFrame(); + }), DispatcherPriority.Background); // MouseEventHandler PreviewMouseMove += MainPreviewMouseMove;