diff --git a/src/con.rs b/src/con.rs index 37ecd8f..898453a 100644 --- a/src/con.rs +++ b/src/con.rs @@ -7,13 +7,16 @@ use std::os::unix::net::UnixStream; pub fn get_tree() -> ipc::Node { let output = util::swaymsg(&["-t", "get_tree"]); - let result = serde_json::from_str(output.as_str()); + let json = output.as_str(); + let result = serde_json::from_str(json); match result { Ok(node) => node, - Err(e) => { - eprintln!("Error: {}", e); - panic!() + Err(err) => { + panic!( + "Can't read get_tree response: {}\nThe JSON is: {}", + err, json + ); } } } diff --git a/src/demon.rs b/src/demon.rs index 20f9b77..19b27bf 100644 --- a/src/demon.rs +++ b/src/demon.rs @@ -23,8 +23,9 @@ pub fn monitor_window_events( .spawn() .expect("Failed to subscribe to window events"); let stdout: proc::ChildStdout = child.stdout.unwrap(); - let stream = Deserializer::from_reader(stdout).into_iter::(); - for res in stream { + let reader = std::io::BufReader::new(stdout); + let deserializer = Deserializer::from_reader(reader); + for res in deserializer.into_iter::() { match res { Ok(win_ev) => handle_con_event(win_ev, con_props.clone()), Err(err) => eprintln!("Error handling window event:\n{:?}", err), diff --git a/src/ipc.rs b/src/ipc.rs index b7c0dd6..7948f59 100644 --- a/src/ipc.rs +++ b/src/ipc.rs @@ -230,7 +230,8 @@ pub enum ConEvent { WorkspaceEvent { change: WorkspaceEventType, current: Box, - old: Box, + // If the old was empty, it'll be killed => "old": null + old: Option>, }, }