mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-02-22 07:50:08 +01:00
internal/uidriver/glfw: Bug fix: Crash on some operations on native fullscreen mode (macOS)
This change forbids some operations when the wiindow is natively fullscreened on macOS in order to avoid crashes. Closes #1578
This commit is contained in:
parent
343e6d3033
commit
ac2b3620b9
@ -432,13 +432,18 @@ func (u *UserInterface) SetFullscreen(fullscreen bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var update bool
|
var update bool
|
||||||
|
var nativeFullscreen bool
|
||||||
_ = u.t.Call(func() error {
|
_ = u.t.Call(func() error {
|
||||||
update = u.isFullscreen() != fullscreen
|
update = u.isFullscreen() != fullscreen
|
||||||
|
nativeFullscreen = u.isNativeFullscreen()
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
if !update {
|
if !update {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if nativeFullscreen {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
var w, h int
|
var w, h int
|
||||||
_ = u.t.Call(func() error {
|
_ = u.t.Call(func() error {
|
||||||
|
@ -38,6 +38,11 @@ package glfw
|
|||||||
// *x = bounds.origin.x;
|
// *x = bounds.origin.x;
|
||||||
// *y = bounds.origin.y;
|
// *y = bounds.origin.y;
|
||||||
// }
|
// }
|
||||||
|
//
|
||||||
|
// static bool isNativeFullscreen() {
|
||||||
|
// return [[NSApplication sharedApplication] currentSystemPresentationOptions] &
|
||||||
|
// NSApplicationPresentationFullScreen;
|
||||||
|
// }
|
||||||
import "C"
|
import "C"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -82,3 +87,7 @@ func currentMonitorByOS(w *glfw.Window) *glfw.Monitor {
|
|||||||
func (u *UserInterface) nativeWindow() uintptr {
|
func (u *UserInterface) nativeWindow() uintptr {
|
||||||
return u.window.GetCocoaWindow()
|
return u.window.GetCocoaWindow()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (u *UserInterface) isNativeFullscreen() bool {
|
||||||
|
return bool(C.isNativeFullscreen())
|
||||||
|
}
|
||||||
|
@ -61,3 +61,7 @@ func (u *UserInterface) nativeWindow() uintptr {
|
|||||||
// TODO: Implement this.
|
// TODO: Implement this.
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (u *UserInterface) isNativeFullscreen() bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
@ -182,3 +182,7 @@ func currentMonitorByOS(_ *glfw.Window) *glfw.Monitor {
|
|||||||
func (u *UserInterface) nativeWindow() uintptr {
|
func (u *UserInterface) nativeWindow() uintptr {
|
||||||
return u.window.GetWin32Window()
|
return u.window.GetWin32Window()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (u *UserInterface) isNativeFullscreen() bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
@ -48,6 +48,10 @@ func (w *window) SetDecorated(decorated bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_ = w.ui.t.Call(func() error {
|
_ = w.ui.t.Call(func() error {
|
||||||
|
if w.ui.isNativeFullscreen() {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
v := glfw.False
|
v := glfw.False
|
||||||
if decorated {
|
if decorated {
|
||||||
v = glfw.True
|
v = glfw.True
|
||||||
@ -80,6 +84,10 @@ func (w *window) SetResizable(resizable bool) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
_ = w.ui.t.Call(func() error {
|
_ = w.ui.t.Call(func() error {
|
||||||
|
if w.ui.isNativeFullscreen() {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
v := glfw.False
|
v := glfw.False
|
||||||
if resizable {
|
if resizable {
|
||||||
v = glfw.True
|
v = glfw.True
|
||||||
@ -107,6 +115,10 @@ func (w *window) SetFloating(floating bool) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
_ = w.ui.t.Call(func() error {
|
_ = w.ui.t.Call(func() error {
|
||||||
|
if w.ui.isNativeFullscreen() {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
v := glfw.False
|
v := glfw.False
|
||||||
if floating {
|
if floating {
|
||||||
v = glfw.True
|
v = glfw.True
|
||||||
|
3
run.go
3
run.go
@ -254,6 +254,9 @@ func IsFullscreen() bool {
|
|||||||
//
|
//
|
||||||
// SetFullscreen does nothing on browsers or mobiles.
|
// SetFullscreen does nothing on browsers or mobiles.
|
||||||
//
|
//
|
||||||
|
// SetFullscreen does nothing on macOS when the window is fullscreened natively by the macOS desktop
|
||||||
|
// instead of SetFullscreen(true).
|
||||||
|
//
|
||||||
// SetFullscreen is concurrent-safe.
|
// SetFullscreen is concurrent-safe.
|
||||||
func SetFullscreen(fullscreen bool) {
|
func SetFullscreen(fullscreen bool) {
|
||||||
uiDriver().SetFullscreen(fullscreen)
|
uiDriver().SetFullscreen(fullscreen)
|
||||||
|
@ -42,6 +42,9 @@ func IsWindowDecorated() bool {
|
|||||||
// SetWindowDecorated works only on desktops.
|
// SetWindowDecorated works only on desktops.
|
||||||
// SetWindowDecorated does nothing on other platforms.
|
// SetWindowDecorated does nothing on other platforms.
|
||||||
//
|
//
|
||||||
|
// SetWindowDecorated does nothing on macOS when the window is fullscreened natively by the macOS desktop
|
||||||
|
// instead of SetFullscreen(true).
|
||||||
|
//
|
||||||
// SetWindowDecorated is concurrent-safe.
|
// SetWindowDecorated is concurrent-safe.
|
||||||
func SetWindowDecorated(decorated bool) {
|
func SetWindowDecorated(decorated bool) {
|
||||||
if w := uiDriver().Window(); w != nil {
|
if w := uiDriver().Window(); w != nil {
|
||||||
@ -67,6 +70,9 @@ func IsWindowResizable() bool {
|
|||||||
//
|
//
|
||||||
// If SetWindowResizable is called with true and Run is used, SetWindowResizable panics. Use RunGame instead.
|
// If SetWindowResizable is called with true and Run is used, SetWindowResizable panics. Use RunGame instead.
|
||||||
//
|
//
|
||||||
|
// SetWindowResizable does nothing on macOS when the window is fullscreened natively by the macOS desktop
|
||||||
|
// instead of SetFullscreen(true).
|
||||||
|
//
|
||||||
// SetWindowResizable is concurrent-safe.
|
// SetWindowResizable is concurrent-safe.
|
||||||
func SetWindowResizable(resizable bool) {
|
func SetWindowResizable(resizable bool) {
|
||||||
theUIContext.setWindowResizable(resizable)
|
theUIContext.setWindowResizable(resizable)
|
||||||
@ -251,6 +257,9 @@ func IsWindowFloating() bool {
|
|||||||
//
|
//
|
||||||
// SetWindowFloating does nothing on browsers or mobiles.
|
// SetWindowFloating does nothing on browsers or mobiles.
|
||||||
//
|
//
|
||||||
|
// SetWindowFloating does nothing on macOS when the window is fullscreened natively by the macOS desktop
|
||||||
|
// instead of SetFullscreen(true).
|
||||||
|
//
|
||||||
// SetWindowFloating is concurrent-safe.
|
// SetWindowFloating is concurrent-safe.
|
||||||
func SetWindowFloating(float bool) {
|
func SetWindowFloating(float bool) {
|
||||||
if w := uiDriver().Window(); w != nil {
|
if w := uiDriver().Window(); w != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user