mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-11 19:48:54 +01:00
ui: Refactoring: Remove pollEvents
This commit is contained in:
parent
c21fb4d390
commit
80dcec865d
@ -103,6 +103,7 @@ var glfwMouseButtonToMouseButton = map[glfw.MouseButton]driver.MouseButton{
|
|||||||
func (i *Input) Update(window *glfw.Window, scale float64) {
|
func (i *Input) Update(window *glfw.Window, scale float64) {
|
||||||
i.m.Lock()
|
i.m.Lock()
|
||||||
defer i.m.Unlock()
|
defer i.m.Unlock()
|
||||||
|
|
||||||
if !i.callbacksInitialized {
|
if !i.callbacksInitialized {
|
||||||
i.runeBuffer = make([]rune, 0, 1024)
|
i.runeBuffer = make([]rune, 0, 1024)
|
||||||
window.SetCharModsCallback(func(w *glfw.Window, char rune, mods glfw.ModifierKey) {
|
window.SetCharModsCallback(func(w *glfw.Window, char rune, mods glfw.ModifierKey) {
|
||||||
|
@ -713,12 +713,6 @@ func (u *userInterface) actualScreenScale() float64 {
|
|||||||
return u.getScale() * devicescale.GetAt(u.currentMonitor().GetPos())
|
return u.getScale() * devicescale.GetAt(u.currentMonitor().GetPos())
|
||||||
}
|
}
|
||||||
|
|
||||||
// pollEvents must be called from the main thread.
|
|
||||||
func (u *userInterface) pollEvents() {
|
|
||||||
glfw.PollEvents()
|
|
||||||
input.Get().Update(u.window, u.getScale()*glfwScale())
|
|
||||||
}
|
|
||||||
|
|
||||||
func (u *userInterface) updateGraphicsContext(g GraphicsContext) {
|
func (u *userInterface) updateGraphicsContext(g GraphicsContext) {
|
||||||
actualScale := 0.0
|
actualScale := 0.0
|
||||||
sizeChanged := false
|
sizeChanged := false
|
||||||
@ -766,13 +760,16 @@ func (u *userInterface) update(g GraphicsContext) error {
|
|||||||
u.updateGraphicsContext(g)
|
u.updateGraphicsContext(g)
|
||||||
|
|
||||||
_ = mainthread.Run(func() error {
|
_ = mainthread.Run(func() error {
|
||||||
u.pollEvents()
|
glfw.PollEvents()
|
||||||
|
input.Get().Update(u.window, u.getScale()*glfwScale())
|
||||||
|
|
||||||
defer hooks.ResumeAudio()
|
defer hooks.ResumeAudio()
|
||||||
|
|
||||||
for !u.isRunnableInBackground() && u.window.GetAttrib(glfw.Focused) == 0 {
|
for !u.isRunnableInBackground() && u.window.GetAttrib(glfw.Focused) == 0 {
|
||||||
hooks.SuspendAudio()
|
hooks.SuspendAudio()
|
||||||
// Wait for an arbitrary period to avoid busy loop.
|
// Wait for an arbitrary period to avoid busy loop.
|
||||||
time.Sleep(time.Second / 60)
|
time.Sleep(time.Second / 60)
|
||||||
u.pollEvents()
|
glfw.PollEvents()
|
||||||
if u.window.ShouldClose() {
|
if u.window.ShouldClose() {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user