From 6f3f567b58f376862ce7e4cfcbe4724c9e81d154 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sun, 15 Sep 2024 18:34:10 +0900 Subject: [PATCH] internal/ui: bug fix: recover the cursor mode when capturing fails Closes #2764 --- internal/ui/ui_js.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/internal/ui/ui_js.go b/internal/ui/ui_js.go index 3fa2dea3f..3d35ba6d2 100644 --- a/internal/ui/ui_js.go +++ b/internal/ui/ui_js.go @@ -539,6 +539,10 @@ func (u *UserInterface) init() error { })) document.Call("addEventListener", "pointerlockerror", js.FuncOf(func(this js.Value, args []js.Value) any { 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.") + if u.cursorMode == CursorModeCaptured { + u.recoverCursorMode() + } + u.recoverCursorPosition() return nil })) document.Call("addEventListener", "fullscreenerror", js.FuncOf(func(this js.Value, args []js.Value) any {