try a better way to work around initial occasional window misdrawing on Linux
This commit is contained in:
@@ -50,19 +50,20 @@ func main() {
|
|||||||
myApp.OnExit = mainWindow.Quit
|
myApp.OnExit = mainWindow.Quit
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
|
defaultServer := myApp.ServerManager.GetDefaultServer()
|
||||||
|
if defaultServer == nil {
|
||||||
|
mainWindow.Controller.PromptForFirstServer()
|
||||||
|
} else {
|
||||||
|
mainWindow.Controller.DoConnectToServerWorkflow(defaultServer)
|
||||||
|
}
|
||||||
// TODO: There is a race condition with laying out the window before the
|
// TODO: There is a race condition with laying out the window before the
|
||||||
// window creation animation on Ubuntu (and other DEs?) finishes, where
|
// window creation animation on Ubuntu (and other DEs?) finishes, where
|
||||||
// the window will be misdrawn into a smaller area if the animation hasn't finished.
|
// the window will be misdrawn into a smaller area if the animation hasn't finished.
|
||||||
// This makes it much less likely to occur (not seen on dozens of startups)
|
// This makes it much less likely to occur (not seen on dozens of startups)
|
||||||
// but is a hacky "solution"!
|
// but is a hacky "solution"!
|
||||||
if runtime.GOOS == "linux" {
|
if runtime.GOOS == "linux" {
|
||||||
time.Sleep(250 * time.Millisecond)
|
time.Sleep(350 * time.Millisecond)
|
||||||
}
|
mainWindow.ForceResize()
|
||||||
defaultServer := myApp.ServerManager.GetDefaultServer()
|
|
||||||
if defaultServer == nil {
|
|
||||||
mainWindow.Controller.PromptForFirstServer()
|
|
||||||
} else {
|
|
||||||
mainWindow.Controller.DoConnectToServerWorkflow(defaultServer)
|
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
|||||||
+13
-10
@@ -89,16 +89,7 @@ func NewMainWindow(fyneApp fyne.App, appName, displayAppName, appVersion string,
|
|||||||
m.BottomPanel = NewBottomPanel(app.PlaybackManager, app.ImageManager, m.Controller)
|
m.BottomPanel = NewBottomPanel(app.PlaybackManager, app.ImageManager, m.Controller)
|
||||||
m.container = container.NewBorder(nil, m.BottomPanel, nil, nil, m.BrowsingPane)
|
m.container = container.NewBorder(nil, m.BottomPanel, nil, nil, m.BrowsingPane)
|
||||||
m.Window.SetContent(m.container)
|
m.Window.SetContent(m.container)
|
||||||
|
m.ForceResize()
|
||||||
w := float32(app.Config.Application.WindowWidth)
|
|
||||||
if w <= 1 {
|
|
||||||
w = 1000
|
|
||||||
}
|
|
||||||
h := float32(app.Config.Application.WindowHeight)
|
|
||||||
if h <= 1 {
|
|
||||||
h = 800
|
|
||||||
}
|
|
||||||
m.Window.Resize(fyne.NewSize(w, h))
|
|
||||||
app.PlaybackManager.OnSongChange(func(item mediaprovider.MediaItem, _ *mediaprovider.Track) {
|
app.PlaybackManager.OnSongChange(func(item mediaprovider.MediaItem, _ *mediaprovider.Track) {
|
||||||
if item == nil {
|
if item == nil {
|
||||||
m.Window.SetTitle(displayAppName)
|
m.Window.SetTitle(displayAppName)
|
||||||
@@ -150,6 +141,18 @@ func NewMainWindow(fyneApp fyne.App, appName, displayAppName, appVersion string,
|
|||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *MainWindow) ForceResize() {
|
||||||
|
w := float32(m.App.Config.Application.WindowWidth)
|
||||||
|
if w <= 1 {
|
||||||
|
w = 1000
|
||||||
|
}
|
||||||
|
h := float32(m.App.Config.Application.WindowHeight)
|
||||||
|
if h <= 1 {
|
||||||
|
h = 800
|
||||||
|
}
|
||||||
|
m.Window.Resize(fyne.NewSize(w, h))
|
||||||
|
}
|
||||||
|
|
||||||
func (m *MainWindow) StartupPage() controller.Route {
|
func (m *MainWindow) StartupPage() controller.Route {
|
||||||
switch m.App.Config.Application.StartupPage {
|
switch m.App.Config.Application.StartupPage {
|
||||||
case "Favorites":
|
case "Favorites":
|
||||||
|
|||||||
Reference in New Issue
Block a user