mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
internal/ui: bug fix: fullscreening didn't work correctly on macOS 13
As of macOS 13, a retrieved collectionBehavior included NSWindowCollectionBehaviorFullScreenNone and this prevented the window from being fullscreen. This change fixes this issue by removing the flag NSWindowCollectionBehaviorFullScreenNone when necessary. Closes #2437
This commit is contained in:
parent
a6e121613f
commit
cff99106b6
@ -66,7 +66,11 @@ var (
|
||||
sel_unsignedIntValue = objc.RegisterName("unsignedIntValue")
|
||||
)
|
||||
|
||||
const NSWindowCollectionBehaviorFullScreenPrimary = 1 << 7
|
||||
const (
|
||||
NSWindowCollectionBehaviorManaged = 1 << 2
|
||||
NSWindowCollectionBehaviorFullScreenPrimary = 1 << 7
|
||||
NSWindowCollectionBehaviorFullScreenNone = 1 << 9
|
||||
)
|
||||
|
||||
const (
|
||||
NSWindowStyleMaskResizable = 1 << 3
|
||||
|
@ -280,12 +280,16 @@ func (u *userInterfaceImpl) setNativeFullscreen(fullscreen bool) {
|
||||
// Even though EbitengineWindowDelegate is used, this hack is still required.
|
||||
// toggleFullscreen doesn't work when the window is not resizable.
|
||||
origFullScreen := window.Send(sel_collectionBehavior)&cocoa.NSWindowCollectionBehaviorFullScreenPrimary != 0
|
||||
origCollectionBehavior := window.Send(sel_collectionBehavior)
|
||||
if !origFullScreen {
|
||||
window.Send(sel_setCollectionBehavior, cocoa.NSUInteger(window.Send(sel_collectionBehavior))|cocoa.NSWindowCollectionBehaviorFullScreenPrimary)
|
||||
collectionBehavior := origCollectionBehavior
|
||||
collectionBehavior |= cocoa.NSWindowCollectionBehaviorFullScreenPrimary
|
||||
collectionBehavior &^= cocoa.NSWindowCollectionBehaviorFullScreenNone
|
||||
window.Send(sel_setCollectionBehavior, cocoa.NSUInteger(collectionBehavior))
|
||||
}
|
||||
window.Send(objc.RegisterName("toggleFullScreen:"), 0)
|
||||
if !origFullScreen {
|
||||
window.Send(sel_setCollectionBehavior, cocoa.NSUInteger(window.Send(sel_collectionBehavior))&^cocoa.NSUInteger(cocoa.NSWindowCollectionBehaviorFullScreenPrimary))
|
||||
window.Send(sel_setCollectionBehavior, cocoa.NSUInteger(cocoa.NSUInteger(origCollectionBehavior)))
|
||||
}
|
||||
}
|
||||
|
||||
@ -325,11 +329,12 @@ func (u *userInterfaceImpl) adjustViewSizeAfterFullscreen() {
|
||||
func (u *userInterfaceImpl) setWindowResizingModeForOS(mode WindowResizingMode) {
|
||||
allowFullscreen := mode == WindowResizingModeOnlyFullscreenEnabled ||
|
||||
mode == WindowResizingModeEnabled
|
||||
collectionBehavior := int(objc.ID(u.window.GetCocoaWindow()).Send(sel_collectionBehavior))
|
||||
var collectionBehavior uint
|
||||
if allowFullscreen {
|
||||
collectionBehavior |= cocoa.NSWindowCollectionBehaviorManaged
|
||||
collectionBehavior |= cocoa.NSWindowCollectionBehaviorFullScreenPrimary
|
||||
} else {
|
||||
collectionBehavior &^= cocoa.NSWindowCollectionBehaviorFullScreenPrimary
|
||||
collectionBehavior |= cocoa.NSWindowCollectionBehaviorFullScreenNone
|
||||
}
|
||||
objc.ID(u.window.GetCocoaWindow()).Send(objc.RegisterName("setCollectionBehavior:"), collectionBehavior)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user