Moved event-waiting when not focused to after run_threads()
This commit is contained in:
parent
946c125fd4
commit
82e33dd2de
|
@ -365,10 +365,7 @@ function core.step()
|
||||||
-- update
|
-- update
|
||||||
core.root_view.size.x, core.root_view.size.y = width, height
|
core.root_view.size.x, core.root_view.size.y = width, height
|
||||||
core.root_view:update()
|
core.root_view:update()
|
||||||
if not core.redraw then
|
if not core.redraw then return false end
|
||||||
if not system.window_has_focus() then system.wait_event(0.5) end
|
|
||||||
return
|
|
||||||
end
|
|
||||||
core.redraw = false
|
core.redraw = false
|
||||||
|
|
||||||
-- close unreferenced docs
|
-- close unreferenced docs
|
||||||
|
@ -394,6 +391,7 @@ function core.step()
|
||||||
renderer.set_clip_rect(table.unpack(core.clip_rect_stack[1]))
|
renderer.set_clip_rect(table.unpack(core.clip_rect_stack[1]))
|
||||||
core.root_view:draw()
|
core.root_view:draw()
|
||||||
renderer.end_frame()
|
renderer.end_frame()
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -432,8 +430,11 @@ end)
|
||||||
function core.run()
|
function core.run()
|
||||||
while true do
|
while true do
|
||||||
core.frame_start = system.get_time()
|
core.frame_start = system.get_time()
|
||||||
core.step()
|
local did_redraw = core.step()
|
||||||
run_threads()
|
run_threads()
|
||||||
|
if not did_redraw and not system.window_has_focus() then
|
||||||
|
system.wait_event(0.25)
|
||||||
|
end
|
||||||
local elapsed = system.get_time() - core.frame_start
|
local elapsed = system.get_time() - core.frame_start
|
||||||
system.sleep(math.max(0, 1 / config.fps - elapsed))
|
system.sleep(math.max(0, 1 / config.fps - elapsed))
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue