From 47f569e473f05924645306e715118f7e0d140870 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Tue, 20 Apr 2021 20:09:04 +0900 Subject: [PATCH] internal/uidriver/glfw: Bug fix: setWindowSize could not accept a fullscreen size --- internal/uidriver/glfw/ui.go | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/internal/uidriver/glfw/ui.go b/internal/uidriver/glfw/ui.go index 6c9d8ca3a..2a1f5fa6c 100644 --- a/internal/uidriver/glfw/ui.go +++ b/internal/uidriver/glfw/ui.go @@ -1365,8 +1365,12 @@ func (u *UserInterface) maximizeWindow() { u.window.Maximize() // Call setWindowSize explicitly in order to update the rendering since the callback is disabled now. - w, h := u.window.GetSize() - u.setWindowSize(w, h, u.isFullscreen()) + // Do not call setWindowSize on the fullscreen mode since setWindowSize requires the window size + // before the fullscreen, while window.GetSize() returns the desktop screen size on the fullscreen mode. + if !u.isFullscreen() { + w, h := u.window.GetSize() + u.setWindowSize(w, h, u.isFullscreen()) + } } // iconifyWindow must be called from the main thread. @@ -1394,8 +1398,12 @@ func (u *UserInterface) restoreWindow() { u.window.Restore() // Call setWindowSize explicitly in order to update the rendering since the callback is disabled now. - w, h := u.window.GetSize() - u.setWindowSize(w, h, u.isFullscreen()) + // Do not call setWindowSize on the fullscreen mode since setWindowSize requires the window size + // before the fullscreen, while window.GetSize() returns the desktop screen size on the fullscreen mode. + if !u.isFullscreen() { + w, h := u.window.GetSize() + u.setWindowSize(w, h, u.isFullscreen()) + } } // setWindowDecorated must be called from the main thread. @@ -1469,8 +1477,12 @@ func (u *UserInterface) setWindowPosition(x, y int) { // Call setWindowSize explicitly in order to update the rendering since the callback is disabled now. // This is necessary in some very limited cases (#1606). - w, h := u.window.GetSize() - u.setWindowSize(w, h, u.isFullscreen()) + // Do not call setWindowSize on the fullscreen mode since setWindowSize requires the window size + // before the fullscreen, while window.GetSize() returns the desktop screen size on the fullscreen mode. + if !u.isFullscreen() { + w, h := u.window.GetSize() + u.setWindowSize(w, h, u.isFullscreen()) + } } // setWindowTitle must be called from the main thread.