internal/uidriver/js: Refactoring

This commit is contained in:
Hajime Hoshi 2021-04-16 03:13:12 +09:00
parent ead84553a0
commit 20705d63a3

View File

@ -150,6 +150,9 @@ func (u *UserInterface) SetCursorMode(mode driver.CursorMode) {
} }
func (u *UserInterface) recoverCursorMode() { func (u *UserInterface) recoverCursorMode() {
if theUI.cursorPrevMode == driver.CursorModeCaptured {
panic("js: cursorPrevMode must not be driver.CursorModeCaptured at recoverCursorMode")
}
u.SetCursorMode(u.cursorPrevMode) u.SetCursorMode(u.cursorPrevMode)
} }
@ -388,9 +391,6 @@ func init() {
// A user can exit the pointer lock by pressing ESC. In this case, sync the cursor mode state. // A user can exit the pointer lock by pressing ESC. In this case, sync the cursor mode state.
if theUI.cursorMode == driver.CursorModeCaptured { if theUI.cursorMode == driver.CursorModeCaptured {
if theUI.cursorPrevMode == driver.CursorModeCaptured {
panic("js: cursorPrevMode must not be driver.CursorModeCaptured")
}
theUI.recoverCursorMode() theUI.recoverCursorMode()
} }
theUI.input.recoverCursorPosition() theUI.input.recoverCursorPosition()