internal/ui: bug fix: reset the input state immediately after reading

Before this change, the input state was reset at the end of a tick.
This means that wheel deltas or input chars in a tick might be reset
unexpectedly.

This change fixes the issue by reseting the input state immediately
when reading, so that wheel events and input-char events are preserved.

Updates #2496
Updates #2501
This commit is contained in:
Hajime Hoshi 2022-12-21 00:27:26 +09:00
parent f989f8a9fa
commit a5b6f39ed7
4 changed files with 4 additions and 6 deletions

View File

@ -1411,13 +1411,13 @@ func (u *userInterfaceImpl) resetForTick() {
u.m.Lock()
defer u.m.Unlock()
u.windowBeingClosed = false
u.inputState.resetForTick()
}
func (u *userInterfaceImpl) readInputState(inputState *InputState) {
u.m.Lock()
defer u.m.Unlock()
*inputState = u.inputState
u.inputState.resetForTick()
}
func (u *userInterfaceImpl) Window() Window {

View File

@ -682,10 +682,10 @@ func (u *userInterfaceImpl) SetScreenTransparent(transparent bool) {
func (u *userInterfaceImpl) readInputState(inputState *InputState) {
*inputState = u.inputState
u.inputState.resetForTick()
}
func (u *userInterfaceImpl) resetForTick() {
u.inputState.resetForTick()
}
func (u *userInterfaceImpl) Window() Window {

View File

@ -422,12 +422,10 @@ func (u *userInterfaceImpl) readInputState(inputState *InputState) {
u.m.Lock()
defer u.m.Unlock()
*inputState = u.inputState
u.inputState.resetForTick()
}
func (u *userInterfaceImpl) resetForTick() {
u.m.Lock()
defer u.m.Unlock()
u.inputState.resetForTick()
}
func (u *userInterfaceImpl) Window() Window {

View File

@ -94,10 +94,10 @@ func (*userInterfaceImpl) ScreenSizeInFullscreen() (int, int) {
func (u *userInterfaceImpl) readInputState(inputState *InputState) {
*inputState = u.inputState
u.inputState.resetForTick()
}
func (u *userInterfaceImpl) resetForTick() {
u.inputState.resetForTick()
}
func (*userInterfaceImpl) CursorMode() CursorMode {