This commit is contained in:
Moritz Ruth 2024-02-28 16:48:01 +01:00
parent bc1ced79a8
commit 19a595c21b
Signed by: moritzruth
GPG key ID: C9BBAB79405EE56D
26 changed files with 754 additions and 559 deletions

View file

@ -48,8 +48,14 @@ pub fn run<
description: e.to_string(),
})?;
let should_stop = matches!(event, HandlerEvent::Stop);
h.handle(event);
handler = Either::Left(h);
if should_stop {
break;
}
}
Either::Right(init_handler) => {
let initial_message = serde_json::from_str::<InitialHandlerMessage<KeyConfig, KnobConfig>>(&line);

View file

@ -42,6 +42,7 @@ pub enum KeyEvent {
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
#[serde(tag = "type", rename_all = "kebab-case")]
pub enum HandlerEvent {
Stop,
Knob { path: KnobPath, event: KnobEvent },
Key { path: KeyPath, event: KeyEvent },
}

View file

@ -374,7 +374,7 @@ impl PaThread {
let current_state = Arc::clone(&self.current_state);
let mainloop = Rc::clone(&self.mainloop);
loop {
'outer: loop {
self.run_single_mainloop_iteration(false);
while let Ok(command) = self.commands_rx.try_recv() {
@ -403,11 +403,13 @@ impl PaThread {
}
}
PaCommand::Terminate => {
mainloop.borrow_mut().quit(Retval(0));
break 'outer;
}
}
}
}
mainloop.borrow_mut().quit(Retval(0));
}
fn unwrap_state(state: &Arc<RwLock<Option<Arc<PaVolumeState>>>>) -> Arc<PaVolumeState> {