From d999f9511b293804adc7b802e9c2bf8947575777 Mon Sep 17 00:00:00 2001 From: galister <22305755+galister@users.noreply.github.com> Date: Mon, 15 Apr 2024 11:10:15 +0900 Subject: [PATCH] redraw at 1s interval --- src/backend/uidev/mod.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/backend/uidev/mod.rs b/src/backend/uidev/mod.rs index 3879db6..34961a3 100644 --- a/src/backend/uidev/mod.rs +++ b/src/backend/uidev/mod.rs @@ -126,6 +126,7 @@ pub fn uidev_run(panel_name: &str) -> anyhow::Result<()> { let watch_path = config_io::CONFIG_ROOT_PATH.join(format!("{}.yaml", panel_name)); let mut path_last_modified = watch_path.metadata()?.modified()?; let mut recreate = false; + let mut last_draw = std::time::Instant::now(); event_loop.run(move |event, elwt| { elwt.set_control_flow(ControlFlow::Poll); @@ -190,6 +191,7 @@ pub fn uidev_run(panel_name: &str) -> anyhow::Result<()> { window.request_redraw(); } cmd_buf.end_rendering().unwrap(); + last_draw = std::time::Instant::now(); let command_buffer = cmd_buf.build().unwrap(); let future = previous_frame_end @@ -223,6 +225,11 @@ pub fn uidev_run(panel_name: &str) -> anyhow::Result<()> { } } } + Event::AboutToWait => { + if last_draw.elapsed().as_secs() > 1 { + window.request_redraw(); + } + } _ => (), } })?;