From b509ce523d456450d98d1b20871bf2104fc3c8d1 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Wed, 28 Apr 2021 23:28:55 +0900 Subject: [PATCH] internal/uidriver/js: Bug fix: SetFullscreen didn't work on Safari Updates #1611 --- internal/uidriver/js/ui_js.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/internal/uidriver/js/ui_js.go b/internal/uidriver/js/ui_js.go index 9d3751a5c..166cd19c3 100644 --- a/internal/uidriver/js/ui_js.go +++ b/internal/uidriver/js/ui_js.go @@ -102,7 +102,6 @@ func (u *UserInterface) SetFullscreen(fullscreen bool) { f := canvas.Get("requestFullscreen") if !f.Truthy() { f = canvas.Get("webkitRequestFullscreen") - return } f.Call("bind", canvas).Invoke() return @@ -422,11 +421,15 @@ func init() { return nil })) document.Call("addEventListener", "pointerlockerror", js.FuncOf(func(this js.Value, args []js.Value) interface{} { - js.Global().Get("console").Call("error", "pointerlockerror event is fired. 'sandbox=\"allow-pointer-lock\"' might be required. There is a known issue on Safari (hajimehoshi/ebiten#1604)") + js.Global().Get("console").Call("error", "pointerlockerror event is fired. 'sandbox=\"allow-pointer-lock\"' might be required at an iframe. This function on browsers must be called as a result of a gestural interaction or orientation change.") return nil })) document.Call("addEventListener", "fullscreenerror", js.FuncOf(func(this js.Value, args []js.Value) interface{} { - js.Global().Get("console").Call("error", "fullscreenerror event is fired. This function on browsers must be called as a result of a gestural interaction or orientation change.") + js.Global().Get("console").Call("error", "fullscreenerror event is fired. 'sandbox=\"fullscreen\"' might be required at an iframe. This function on browsers must be called as a result of a gestural interaction or orientation change.") + return nil + })) + document.Call("addEventListener", "webkitfullscreenerror", js.FuncOf(func(this js.Value, args []js.Value) interface{} { + js.Global().Get("console").Call("error", "webkitfullscreenerror event is fired. 'sandbox=\"fullscreen\"' might be required at an iframe. This function on browsers must be called as a result of a gestural interaction or orientation change.") return nil })) }