From 6ec6e385d47013003ba914db83201eae2ca97bff Mon Sep 17 00:00:00 2001 From: Andy Williams Date: Fri, 26 Jun 2020 11:56:24 +0100 Subject: [PATCH 1/2] Fix certain issues with Resize and FixedSize windows This is pretty much Linux specific due to the order of resize operations and scale detection. Fixes #1105 --- internal/driver/glfw/window.go | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/internal/driver/glfw/window.go b/internal/driver/glfw/window.go index bb884e4989..2b2843e545 100644 --- a/internal/driver/glfw/window.go +++ b/internal/driver/glfw/window.go @@ -157,15 +157,19 @@ func (w *window) RequestFocus() { } func (w *window) Resize(size fyne.Size) { - w.canvas.Resize(size) - w.viewLock.Lock() - if w.fixedSize || !w.visible { // fixed size ignores future `resized` and if not visible we may not get the event - w.width, w.height = internal.ScaleInt(w.canvas, size.Width), internal.ScaleInt(w.canvas, size.Height) - } - w.viewLock.Unlock() + // we cannot perform this until window is prepared as we don't know it's scale! w.runOnMainWhenCreated(func() { - w.viewport.SetSize(w.width, w.height) + w.canvas.Resize(size) + w.viewLock.Lock() + + width, height := internal.ScaleInt(w.canvas, size.Width), internal.ScaleInt(w.canvas, size.Height) + if w.fixedSize || !w.visible { // fixed size ignores future `resized` and if not visible we may not get the event + w.width, w.height = width, height + } + w.viewLock.Unlock() + + w.viewport.SetSize(width, height) w.fitContent() }) } From 4c70c2d88443e2ad2dfa5b47d9f423baf694d6f2 Mon Sep 17 00:00:00 2001 From: Andy Williams Date: Fri, 26 Jun 2020 11:58:33 +0100 Subject: [PATCH 2/2] Only use textureScale on macOS This is darwin specific and some linux systems were triggering it by mistake. May fix #1103 --- internal/driver/glfw/window.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/driver/glfw/window.go b/internal/driver/glfw/window.go index 2b2843e545..5a1e22b476 100644 --- a/internal/driver/glfw/window.go +++ b/internal/driver/glfw/window.go @@ -495,7 +495,7 @@ func (w *window) resized(_ *glfw.Window, width, height int) { } func (w *window) frameSized(viewport *glfw.Window, width, height int) { - if width == 0 || height == 0 { + if width == 0 || height == 0 || runtime.GOOS != "darwin" { return }