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 { pub fn get_tree() -> ipc::Node {
let output = util::swaymsg(&["-t", "get_tree"]); 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 { match result {
Ok(node) => node, Ok(node) => node,
Err(e) => { Err(err) => {
eprintln!("Error: {}", e); panic!(
panic!() "Can't read get_tree response: {}\nThe JSON is: {}",
err, json
);
} }
} }
} }

@ -23,8 +23,9 @@ pub fn monitor_window_events(
.spawn() .spawn()
.expect("Failed to subscribe to window events"); .expect("Failed to subscribe to window events");
let stdout: proc::ChildStdout = child.stdout.unwrap(); let stdout: proc::ChildStdout = child.stdout.unwrap();
let stream = Deserializer::from_reader(stdout).into_iter::<ipc::ConEvent>(); let reader = std::io::BufReader::new(stdout);
for res in stream { let deserializer = Deserializer::from_reader(reader);
for res in deserializer.into_iter::<ipc::ConEvent>() {
match res { match res {
Ok(win_ev) => handle_con_event(win_ev, con_props.clone()), Ok(win_ev) => handle_con_event(win_ev, con_props.clone()),
Err(err) => eprintln!("Error handling window event:\n{:?}", err), Err(err) => eprintln!("Error handling window event:\n{:?}", err),

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

Loading…
Cancel
Save