only use X11 resize hack when needed
This commit is contained in:
@@ -60,9 +60,14 @@ func main() {
|
||||
// hacky workaround for https://github.com/fyne-io/fyne/issues/4964
|
||||
if runtime.GOOS == "linux" {
|
||||
time.Sleep(350 * time.Millisecond)
|
||||
w, h := mainWindow.DesiredSize()
|
||||
scale := mainWindow.Window.Canvas().Scale()
|
||||
SendResizeToPID(os.Getpid(), int(w*scale), int(h*scale))
|
||||
canvas := mainWindow.Window.Canvas()
|
||||
size := canvas.Size()
|
||||
desired := mainWindow.DesiredSize()
|
||||
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))
|
||||
}
|
||||
}
|
||||
|
||||
}()
|
||||
@@ -82,3 +87,10 @@ func main() {
|
||||
log.Println("Running shutdown tasks...")
|
||||
myApp.Shutdown()
|
||||
}
|
||||
|
||||
func inDelta(a, b fyne.Size, delta float32) bool {
|
||||
diffW := a.Width - b.Width
|
||||
diffH := a.Height - b.Height
|
||||
return diffW < delta && diffW > -delta &&
|
||||
diffH < delta && diffH > -delta
|
||||
}
|
||||
|
||||
+5
-6
@@ -141,21 +141,20 @@ func NewMainWindow(fyneApp fyne.App, appName, displayAppName, appVersion string,
|
||||
return m
|
||||
}
|
||||
|
||||
func (m *MainWindow) DesiredSize() (w, h float32) {
|
||||
w = float32(m.App.Config.Application.WindowWidth)
|
||||
func (m *MainWindow) DesiredSize() fyne.Size {
|
||||
w := float32(m.App.Config.Application.WindowWidth)
|
||||
if w <= 1 {
|
||||
w = 1000
|
||||
}
|
||||
h = float32(m.App.Config.Application.WindowHeight)
|
||||
h := float32(m.App.Config.Application.WindowHeight)
|
||||
if h <= 1 {
|
||||
h = 800
|
||||
}
|
||||
return w, h
|
||||
return fyne.NewSize(w, h)
|
||||
}
|
||||
|
||||
func (m *MainWindow) setInitialSize() {
|
||||
w, h := m.DesiredSize()
|
||||
m.Window.Resize(fyne.NewSize(w, h))
|
||||
m.Window.Resize(m.DesiredSize())
|
||||
}
|
||||
|
||||
func (m *MainWindow) StartupPage() controller.Route {
|
||||
|
||||
Reference in New Issue
Block a user