use Resize twice

This commit is contained in:
Drew Weymouth
2024-08-07 12:46:11 -07:00
parent f4a5d4aab3
commit 1ff9d2d026
+5 -5
View File
@@ -6,11 +6,13 @@ import (
"log" "log"
"os" "os"
"sync" "sync"
"time"
"github.com/dweymouth/supersonic/backend" "github.com/dweymouth/supersonic/backend"
"github.com/dweymouth/supersonic/res" "github.com/dweymouth/supersonic/res"
"github.com/dweymouth/supersonic/ui" "github.com/dweymouth/supersonic/ui"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app" "fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/lang" "fyne.io/fyne/v2/lang"
) )
@@ -61,12 +63,10 @@ func main() {
// slightly hacky workaround for https://github.com/fyne-io/fyne/issues/4964 // slightly hacky workaround for https://github.com/fyne-io/fyne/issues/4964
workaroundWindowSize := sync.OnceFunc(func() { workaroundWindowSize := sync.OnceFunc(func() {
time.Sleep(10 * time.Millisecond)
s := mainWindow.DesiredSize() s := mainWindow.DesiredSize()
scale := mainWindow.Window.Canvas().Scale() mainWindow.Window.Resize(s.Subtract(fyne.NewSize(2, 0)))
s.Width *= scale mainWindow.Window.Resize(s) // back to desired size
s.Height *= scale
// exported in Supersonic Fyne fork
mainWindow.Window.ProcessResized(int(s.Width), int(s.Height))
}) })
fyneApp.Lifecycle().SetOnEnteredForeground(func() { fyneApp.Lifecycle().SetOnEnteredForeground(func() {
workaroundWindowSize() workaroundWindowSize()