From 99a15d81f46cd80c2c7a6123a0c5a014e8f632f6 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Wed, 26 Jan 2022 04:29:09 +0900 Subject: [PATCH] internal/uidriver/glfw: bug fix: needed to set the window position after restoring from fullscreen Closes #1975 --- internal/uidriver/glfw/ui.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/internal/uidriver/glfw/ui.go b/internal/uidriver/glfw/ui.go index 42493e705..14c8dc0d8 100644 --- a/internal/uidriver/glfw/ui.go +++ b/internal/uidriver/glfw/ui.go @@ -1251,6 +1251,16 @@ func (u *UserInterface) setWindowSizeInDIPImpl(width, height int, fullscreen boo if u.isNativeFullscreenAvailable() && u.isNativeFullscreen() { u.setNativeFullscreen(false) + + // Reset the window size and the position explicitly (#1975). + // Polling an event is necessary to set the window size correctly + // after restoring from the fullscreen. + glfw.PollEvents() + ww := int(u.dipToGLFWPixel(float64(width), u.currentMonitor())) + wh := int(u.dipToGLFWPixel(float64(height), u.currentMonitor())) + u.window.SetSize(ww, wh) + + // TODO: Set the window position correctly if possible. } else if !u.isNativeFullscreenAvailable() && u.window.GetMonitor() != nil { if u.Graphics().IsGL() { // When OpenGL is used, swapping buffer is enough to solve the image-lag