Fix a deserialization error with workspace events

timeout_old
Tassilo Horn 4 years ago
parent a17271a918
commit 30770c8e5c
  1. 11
      src/con.rs
  2. 5
      src/demon.rs
  3. 3
      src/ipc.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
);
}
}
}

@ -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::<ipc::ConEvent>();
for res in stream {
let reader = std::io::BufReader::new(stdout);
let deserializer = Deserializer::from_reader(reader);
for res in deserializer.into_iter::<ipc::ConEvent>() {
match res {
Ok(win_ev) => handle_con_event(win_ev, con_props.clone()),
Err(err) => eprintln!("Error handling window event:\n{:?}", err),

@ -230,7 +230,8 @@ pub enum ConEvent {
WorkspaceEvent {
change: WorkspaceEventType,
current: Box<Node>,
old: Box<Node>,
// If the old was empty, it'll be killed => "old": null
old: Option<Box<Node>>,
},
}

Loading…
Cancel
Save