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.