internal/ui: update touches after the layout is determined on mobiles

Closes #2763
This commit is contained in:
Hajime Hoshi 2023-09-17 21:48:42 +09:00
parent 07d2706e63
commit 8a0aba45f5
2 changed files with 15 additions and 6 deletions

View File

@ -37,19 +37,27 @@ func (u *userInterfaceImpl) updateInputStateFromOutside(keys map[Key]struct{}, r
u.inputState.Runes = append(u.inputState.Runes, runes...)
u.inputState.Touches = u.inputState.Touches[:0]
u.touches = u.touches[:0]
for _, t := range touches {
x, y := u.context.clientPositionToLogicalPosition(t.X, t.Y, u.DeviceScaleFactor())
u.touches = append(u.touches, t)
}
}
func (u *userInterfaceImpl) updateInputState() error {
u.m.Lock()
defer u.m.Unlock()
s := u.DeviceScaleFactor()
u.inputState.Touches = u.inputState.Touches[:0]
for _, t := range u.touches {
x, y := u.context.clientPositionToLogicalPosition(t.X, t.Y, s)
u.inputState.Touches = append(u.inputState.Touches, Touch{
ID: t.ID,
X: int(x),
Y: int(y),
})
}
}
func (u *userInterfaceImpl) updateInputState() error {
// TODO: Adjust cursor and touch positions based on the latest layout (#2763).
return nil
}

View File

@ -114,6 +114,7 @@ type userInterfaceImpl struct {
context *context
inputState InputState
touches []TouchForInput
fpsMode FPSModeType
renderRequester RenderRequester