From d8734083de747bd31cd5039a1ad6c6498d8a56c1 Mon Sep 17 00:00:00 2001 From: Drew Weymouth Date: Tue, 10 Feb 2026 20:16:19 -0800 Subject: [PATCH] fix content not loading on startup until window focused --- main.go | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/main.go b/main.go index d431273..de68eef 100644 --- a/main.go +++ b/main.go @@ -111,15 +111,8 @@ func main() { myApp.OnReactivate = util.FyneDoFunc(mainWindow.Show) myApp.OnExit = util.FyneDoFunc(mainWindow.Quit) - windowStartupTasks := sync.OnceFunc(func() { - defaultServer := myApp.ServerManager.GetDefaultServer() - if defaultServer == nil { - mainWindow.Controller.PromptForFirstServer() - } else if !*backend.FlagStartMinimized { // If the minimized start flag was passed, the connection is already established. - mainWindow.Controller.DoConnectToServerWorkflow(defaultServer) - } - - if runtime.GOOS == "windows" { + if runtime.GOOS == "windows" { + windowStartupTasks := sync.OnceFunc(func() { mainWindow.Window.(driver.NativeWindow).RunNative(func(ctx any) { hwnd := ctx.(driver.WindowsWindowContext).HWND if myApp.Config.Application.EnableOSMediaPlayerAPIs { @@ -127,9 +120,9 @@ func main() { } myApp.SetupWindowsTaskbarButtons(hwnd) }) - } - }) - fyneApp.Lifecycle().SetOnEnteredForeground(windowStartupTasks) + }) + fyneApp.Lifecycle().SetOnEnteredForeground(windowStartupTasks) + } if *backend.FlagStartMinimized { if err = myApp.LoginToDefaultServer(); err != nil { @@ -138,6 +131,15 @@ func main() { } fyneApp.Run() } else { + fyneApp.Lifecycle().SetOnStarted(func() { + defaultServer := myApp.ServerManager.GetDefaultServer() + if defaultServer == nil { + mainWindow.Controller.PromptForFirstServer() + } else if !*backend.FlagStartMinimized { // If the minimized start flag was passed, the connection is already established. + mainWindow.Controller.DoConnectToServerWorkflow(defaultServer) + } + }) + mainWindow.ShowAndRun() }