From 6ec6e385d47013003ba914db83201eae2ca97bff Mon Sep 17 00:00:00 2001 From: Andy Williams Date: Fri, 26 Jun 2020 11:56:24 +0100 Subject: [PATCH] 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() }) }