From af52bfacad04b9c362b75b78d68f17f8f7529dd2 Mon Sep 17 00:00:00 2001 From: Brady Fomegne Date: Wed, 24 Apr 2024 10:04:11 +0100 Subject: [PATCH] fix: unless sending of idle state Now, we modify directly the idle state value when the frontend want to change the idle state. It was a mistake to use the key events to trigger it. --- service/src/lib.rs | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/service/src/lib.rs b/service/src/lib.rs index e685f60..65ae2ab 100644 --- a/service/src/lib.rs +++ b/service/src/lib.rs @@ -83,20 +83,6 @@ pub fn run( // We process event. for event in event_rx.iter() { - // Consult the frontend to know if there have some requests. - frontend_tx1.send(GUICmd::NOP)?; - match frontend_rx2.recv()? { - GUICmd::End => break, - GUICmd::State(state) => { - if state { - rdev::simulate(&EventType::KeyPress(E_Key::Pause)).unwrap(); - } else { - rdev::simulate(&EventType::KeyRelease(E_Key::Pause)).unwrap(); - } - } - _ => (), - } - match event.event_type { // Handling of idle state. EventType::KeyPress(E_Key::Pause) => { @@ -196,6 +182,17 @@ pub fn run( } }; } + + // Consult the frontend to know if there have some requests. + frontend_tx1.send(GUICmd::NOP)?; + match frontend_rx2.recv()? { + GUICmd::End => break, + GUICmd::State(state) => { + idle = state; + frontend_tx1.send(GUICmd::State(idle))?; + } + _ => (), + } } // Wait the frontend to end properly.