Skip to content

Commit

Permalink
fix: unless sending of idle state
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
pythonbrad committed Apr 24, 2024
1 parent 0367118 commit af52bfa
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit af52bfa

Please sign in to comment.