Skip to content

Commit 53cb94d

Browse files
committed
Fix first load issue
1 parent 270f5b3 commit 53cb94d

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

Flow.Launcher.Core/Resource/Theme.cs

+10
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,12 @@ public static int SetWindowAttribute(IntPtr hwnd, ParameterTypes.DWMWINDOWATTRIB
108108
public void RefreshFrame()
109109
{
110110
IntPtr mainWindowPtr = new WindowInteropHelper(mainWindow).Handle;
111+
if (mainWindowPtr == IntPtr.Zero)
112+
return;
113+
111114
HwndSource mainWindowSrc = HwndSource.FromHwnd(mainWindowPtr);
115+
if (mainWindowSrc == null)
116+
return;
112117
//mainWindowSrc.CompositionTarget.BackgroundColor = Color.FromArgb(0, 255, 181, 178);
113118

114119
ParameterTypes.MARGINS margins = new ParameterTypes.MARGINS();
@@ -136,7 +141,12 @@ public void SetBlurForWindow()
136141

137142
//SetWindowAccent();
138143
var dict = GetThemeResourceDictionary(Settings.Theme);
144+
if (dict == null)
145+
return;
146+
139147
var windowBorderStyle = dict["WindowBorderStyle"] as Style;
148+
if (windowBorderStyle == null)
149+
return;
140150
Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_SYSTEMBACKDROP_TYPE, 3);
141151
if (BlurEnabled)
142152
{

Flow.Launcher/MainWindow.xaml.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,10 @@ private void OnInitialized(object sender, EventArgs e)
181181

182182
private void OnLoaded(object sender, RoutedEventArgs _)
183183
{
184-
ThemeManager.Instance.RefreshFrame();
184+
Dispatcher.BeginInvoke((Action)(() =>
185+
{
186+
ThemeManager.Instance.RefreshFrame();
187+
}), DispatcherPriority.Background);
185188

186189
// MouseEventHandler
187190
PreviewMouseMove += MainPreviewMouseMove;

0 commit comments

Comments
 (0)