add retrying to Fyne window misdraw workaround on Linux

This commit is contained in:
Drew Weymouth
2024-07-24 07:45:35 -07:00
parent 6d08bfbd79
commit 26c3bd8012
+10 -1
View File
@@ -69,7 +69,16 @@ func main() {
if !inDelta(size, desired, 1) {
// window drawn at incorrect size on startup
scale := canvas.Scale()
SendResizeToPID(os.Getpid(), int(desired.Width*scale), int(desired.Height*scale))
for i := 0; i < 3 && !inDelta(size, desired, 1); i++ {
if i > 0 {
// if resize didn't work the first time, try again with slightly
// different desired size
desired.Subtract(fyne.NewSize(2, 2))
}
SendResizeToPID(os.Getpid(), int(desired.Width*scale), int(desired.Height*scale))
time.Sleep(100 * time.Millisecond)
size = canvas.Size()
}
}
}