mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 02:38:53 +01:00
ui: Refactoring
This commit is contained in:
parent
e11bc62059
commit
cad051437d
@ -29,7 +29,7 @@ var glfwMouseButtonToMouseButton = map[glfw.MouseButton]MouseButton{
|
||||
glfw.MouseButtonMiddle: MouseButtonMiddle,
|
||||
}
|
||||
|
||||
func (i *input) update(window *glfw.Window, scale float64) error {
|
||||
func (i *input) update(window *glfw.Window, scale float64) {
|
||||
i.m.Lock()
|
||||
defer i.m.Unlock()
|
||||
|
||||
@ -65,5 +65,4 @@ func (i *input) update(window *glfw.Window, scale float64) error {
|
||||
i.gamepads[id].buttonPressed[b] = glfw.Action(buttons[b]) == glfw.Press
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -210,9 +210,9 @@ func (u *userInterface) actualScreenScale() float64 {
|
||||
return u.scale * deviceScale()
|
||||
}
|
||||
|
||||
func (u *userInterface) pollEvents() error {
|
||||
func (u *userInterface) pollEvents() {
|
||||
glfw.PollEvents()
|
||||
return currentInput.update(u.window, u.scale*glfwScale())
|
||||
currentInput.update(u.window, u.scale*glfwScale())
|
||||
}
|
||||
|
||||
func (u *userInterface) update(g GraphicsContext) error {
|
||||
@ -240,24 +240,18 @@ func (u *userInterface) update(g GraphicsContext) error {
|
||||
}
|
||||
}
|
||||
|
||||
if err := u.runOnMainThread(func() error {
|
||||
if err := u.pollEvents(); err != nil {
|
||||
return err
|
||||
}
|
||||
_ = u.runOnMainThread(func() error {
|
||||
u.pollEvents()
|
||||
for u.window.GetAttrib(glfw.Focused) == 0 {
|
||||
// Wait for an arbitrary period to avoid busy loop.
|
||||
time.Sleep(time.Second / 60)
|
||||
if err := u.pollEvents(); err != nil {
|
||||
return err
|
||||
}
|
||||
u.pollEvents()
|
||||
if u.window.ShouldClose() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
})
|
||||
if err := g.Update(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user