internal/ui: reland: bug fix: disable window size limitation on fullscreen

Closes #2260
This commit is contained in:
Hajime Hoshi 2023-09-16 16:49:49 +09:00
parent 40fc96d78c
commit 45acc2c5d8
2 changed files with 15 additions and 0 deletions

View File

@ -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?

View File

@ -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()
},
},
{