fix content not loading on startup until window focused

This commit is contained in:
Drew Weymouth
2026-02-10 20:16:29 -08:00
parent 928713eb5e
commit d8734083de
+14 -12
View File
@@ -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()
}