hacky solution to avoid occasional window misdrawing on startup
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
|||||||
"path"
|
"path"
|
||||||
"supersonic/backend"
|
"supersonic/backend"
|
||||||
"supersonic/ui"
|
"supersonic/ui"
|
||||||
|
"time"
|
||||||
|
|
||||||
"fyne.io/fyne/v2/app"
|
"fyne.io/fyne/v2/app"
|
||||||
"github.com/20after4/configdir"
|
"github.com/20after4/configdir"
|
||||||
@@ -28,6 +29,14 @@ func main() {
|
|||||||
|
|
||||||
fyneApp := app.New()
|
fyneApp := app.New()
|
||||||
mainWindow := ui.NewMainWindow(fyneApp, appname, myApp)
|
mainWindow := ui.NewMainWindow(fyneApp, appname, myApp)
|
||||||
|
|
||||||
|
// TODO: There is some race condition with running this initial startup
|
||||||
|
// task immediately before showing and running the window/Fyne main loop where
|
||||||
|
// the window can occasionally get misdrawn on startup. (Only seen on Ubuntu so far).
|
||||||
|
// This makes it much less likely to occur (not seen on dozens of startups)
|
||||||
|
// but is a hacky "solution"!
|
||||||
|
go func() {
|
||||||
|
time.Sleep(75 * time.Millisecond)
|
||||||
defaultServer := myApp.Config.GetDefaultServer()
|
defaultServer := myApp.Config.GetDefaultServer()
|
||||||
if defaultServer == nil {
|
if defaultServer == nil {
|
||||||
mainWindow.PromptForFirstServer(func(nick, host, user, pass string) {
|
mainWindow.PromptForFirstServer(func(nick, host, user, pass string) {
|
||||||
@@ -42,10 +51,10 @@ func main() {
|
|||||||
} else {
|
} else {
|
||||||
setupServer(myApp, defaultServer)
|
setupServer(myApp, defaultServer)
|
||||||
}
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
mainWindow.Show()
|
mainWindow.Show()
|
||||||
fyneApp.Run()
|
fyneApp.Run()
|
||||||
|
|
||||||
myApp.Config.WriteConfigFile(configPath())
|
myApp.Config.WriteConfigFile(configPath())
|
||||||
myApp.Shutdown()
|
myApp.Shutdown()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user