From fbe69615284c2bacedb23510c292ac8021df845d Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Tue, 20 Apr 2021 22:53:15 +0900 Subject: [PATCH] internal/uidriver/glfw: Bug fix: Delay to enable SetSize callback On Linux, the SetSize callback is invoked with an unexpected value at the initial phase. Just delay it until the initialization finishes. --- internal/uidriver/glfw/ui.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/uidriver/glfw/ui.go b/internal/uidriver/glfw/ui.go index 2a1f5fa6c..fa73b3d2e 100644 --- a/internal/uidriver/glfw/ui.go +++ b/internal/uidriver/glfw/ui.go @@ -814,7 +814,6 @@ func (u *UserInterface) init() error { if err := u.createWindow(); err != nil { return err } - u.setSizeCallbackEnabled = true setSize := func() { ww, wh := u.getInitWindowSize() @@ -849,6 +848,10 @@ func (u *UserInterface) init() error { g.SetWindow(u.nativeWindow()) } + // Enable the SetSize callback after all the initialization finishes. Or, unexpected the callback + // is fired unexpectedly at the initial phase with a very small size on Linux. + u.setSizeCallbackEnabled = true + return nil }