internal/ui: forbid a green button when a max window size limit is specified

Updates #2260
This commit is contained in:
Hajime Hoshi 2023-09-16 16:30:02 +09:00
parent 128215eedd
commit 40fc96d78c
2 changed files with 17 additions and 3 deletions

View File

@ -1319,6 +1319,9 @@ func (u *userInterfaceImpl) updateWindowSizeLimits() {
maxh = int(u.dipToGLFWPixel(float64(maxh), m))
}
u.window.SetSizeLimits(minw, minh, maxw, maxh)
// The window size limit affects the resizing mode, especially on macOS (#).
u.setWindowResizingModeForOS(u.windowResizingMode)
}
// adjustWindowSizeBasedOnSizeLimitsInDIP adjust the size based on the window size limits.

View File

@ -348,11 +348,22 @@ func (u *userInterfaceImpl) adjustViewSizeAfterFullscreen() {
window.SetBackgroundColor(cocoa.NSColor_colorWithSRGBRedGreenBlueAlpha(0, 0, 0, 0))
}
func (u *userInterfaceImpl) isFullscreenAllowedFromUI(mode WindowResizingMode) bool {
if u.maxWindowWidthInDIP != glfw.DontCare || u.maxWindowHeightInDIP != glfw.DontCare {
return false
}
if mode == WindowResizingModeOnlyFullscreenEnabled {
return true
}
if mode == WindowResizingModeEnabled {
return true
}
return false
}
func (u *userInterfaceImpl) setWindowResizingModeForOS(mode WindowResizingMode) {
allowFullscreen := mode == WindowResizingModeOnlyFullscreenEnabled ||
mode == WindowResizingModeEnabled
var collectionBehavior uint
if allowFullscreen {
if u.isFullscreenAllowedFromUI(mode) {
collectionBehavior |= cocoa.NSWindowCollectionBehaviorManaged
collectionBehavior |= cocoa.NSWindowCollectionBehaviorFullScreenPrimary
} else {