mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +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")
|
sel_unsignedIntValue = objc.RegisterName("unsignedIntValue")
|
||||||
)
|
)
|
||||||
|
|
||||||
const NSWindowCollectionBehaviorFullScreenPrimary = 1 << 7
|
const (
|
||||||
|
NSWindowCollectionBehaviorManaged = 1 << 2
|
||||||
|
NSWindowCollectionBehaviorFullScreenPrimary = 1 << 7
|
||||||
|
NSWindowCollectionBehaviorFullScreenNone = 1 << 9
|
||||||
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
NSWindowStyleMaskResizable = 1 << 3
|
NSWindowStyleMaskResizable = 1 << 3
|
||||||
|
@ -280,12 +280,16 @@ func (u *userInterfaceImpl) setNativeFullscreen(fullscreen bool) {
|
|||||||
// Even though EbitengineWindowDelegate is used, this hack is still required.
|
// Even though EbitengineWindowDelegate is used, this hack is still required.
|
||||||
// toggleFullscreen doesn't work when the window is not resizable.
|
// toggleFullscreen doesn't work when the window is not resizable.
|
||||||
origFullScreen := window.Send(sel_collectionBehavior)&cocoa.NSWindowCollectionBehaviorFullScreenPrimary != 0
|
origFullScreen := window.Send(sel_collectionBehavior)&cocoa.NSWindowCollectionBehaviorFullScreenPrimary != 0
|
||||||
|
origCollectionBehavior := window.Send(sel_collectionBehavior)
|
||||||
if !origFullScreen {
|
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)
|
window.Send(objc.RegisterName("toggleFullScreen:"), 0)
|
||||||
if !origFullScreen {
|
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) {
|
func (u *userInterfaceImpl) setWindowResizingModeForOS(mode WindowResizingMode) {
|
||||||
allowFullscreen := mode == WindowResizingModeOnlyFullscreenEnabled ||
|
allowFullscreen := mode == WindowResizingModeOnlyFullscreenEnabled ||
|
||||||
mode == WindowResizingModeEnabled
|
mode == WindowResizingModeEnabled
|
||||||
collectionBehavior := int(objc.ID(u.window.GetCocoaWindow()).Send(sel_collectionBehavior))
|
var collectionBehavior uint
|
||||||
if allowFullscreen {
|
if allowFullscreen {
|
||||||
|
collectionBehavior |= cocoa.NSWindowCollectionBehaviorManaged
|
||||||
collectionBehavior |= cocoa.NSWindowCollectionBehaviorFullScreenPrimary
|
collectionBehavior |= cocoa.NSWindowCollectionBehaviorFullScreenPrimary
|
||||||
} else {
|
} else {
|
||||||
collectionBehavior &^= cocoa.NSWindowCollectionBehaviorFullScreenPrimary
|
collectionBehavior |= cocoa.NSWindowCollectionBehaviorFullScreenNone
|
||||||
}
|
}
|
||||||
objc.ID(u.window.GetCocoaWindow()).Send(objc.RegisterName("setCollectionBehavior:"), collectionBehavior)
|
objc.ID(u.window.GetCocoaWindow()).Send(objc.RegisterName("setCollectionBehavior:"), collectionBehavior)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user