From 45acc2c5d8fd8f1c47a5ad85c82fa39d4e429d49 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sat, 16 Sep 2023 16:49:49 +0900 Subject: [PATCH] internal/ui: reland: bug fix: disable window size limitation on fullscreen Closes #2260 --- internal/ui/ui_glfw.go | 11 +++++++++++ internal/ui/ui_glfw_darwin.go | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/internal/ui/ui_glfw.go b/internal/ui/ui_glfw.go index 389cd6fa7..ae88099df 100644 --- a/internal/ui/ui_glfw.go +++ b/internal/ui/ui_glfw.go @@ -1324,6 +1324,14 @@ func (u *userInterfaceImpl) updateWindowSizeLimits() { u.setWindowResizingModeForOS(u.windowResizingMode) } +// disableWindowSizeLimits disables a window size limitation temporarily, especially for fullscreen +// In order to enable the size limitation, call updateWindowSizeLimits. +// +// disableWindowSizeLimits must be called from the main thread. +func (u *userInterfaceImpl) disableWindowSizeLimits() { + u.window.SetSizeLimits(glfw.DontCare, glfw.DontCare, glfw.DontCare, glfw.DontCare) +} + // adjustWindowSizeBasedOnSizeLimitsInDIP adjust the size based on the window size limits. // width and height are in device-independent pixels. func (u *userInterfaceImpl) adjustWindowSizeBasedOnSizeLimitsInDIP(width, height int) (int, int) { @@ -1400,6 +1408,8 @@ func (u *userInterfaceImpl) setFullscreen(fullscreen bool) { // Enter the fullscreen. if fullscreen { + u.disableWindowSizeLimits() + if x, y := u.origWindowPos(); x == invalidPos || y == invalidPos { u.setOrigWindowPos(u.window.GetPos()) } @@ -1420,6 +1430,7 @@ func (u *userInterfaceImpl) setFullscreen(fullscreen bool) { } // Exit the fullscreen. + u.updateWindowSizeLimits() // Get the original window position and size before changing the state of fullscreen. // TODO: Why? diff --git a/internal/ui/ui_glfw_darwin.go b/internal/ui/ui_glfw_darwin.go index e90d8e117..16d8a1a52 100644 --- a/internal/ui/ui_glfw_darwin.go +++ b/internal/ui/ui_glfw_darwin.go @@ -136,6 +136,10 @@ func init() { Cmd: sel_windowWillExitFullScreen, Fn: func(id objc.ID, cmd objc.SEL, notification objc.ID) { pushResizableState(id, cocoa.NSNotification{ID: notification}.Object()) + // Even a window has a size limitation, a window can be fullscreen by calling SetFullscreen(true). + // In this case, the window size limitation is disabled temporarily. + // When exiting from fullscreen, reset the window size limitation. + theUI.updateWindowSizeLimits() }, }, {