Added hack/fix for wlc bug
See bug:
@@ -5,6 +5,8 @@ use super::super::commands::CommandResult;
use uuid::Uuid;
use rustwlc::{WlcView};
+use std::collections::HashSet;
+
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum BackgroundErr {
/// A background (the `WlcView`) is already attached to the output (`UUID`)
@@ -18,22 +20,32 @@ impl LayoutTree {
/// ``
pub fn attach_background(&mut self, bg: WlcView, outputs: &[Uuid])
-> CommandResult {
+ // TODO Remove this to remove when the wlc bug is fixed
+ // https://github.com/Cloudef/wlc/issues/221
+ let mut to_remove = HashSet::with_capacity(outputs.len());
for output_id in outputs {
match *try!(self.lookup_mut(*output_id)) {
Container::Output { ref mut background, .. } => {
if background.is_none() {
*background = Some(bg);
} else {
- error!("HERE");
- error!("{:?}", background.clone());
- return Err(TreeError::Background(
- BackgroundErr::AlreadyAttached(*output_id, background.clone().unwrap())))
+ // TODO This can't be used right now, see this bug:
+ // https://github.com/Cloudef/wlc/issues/221
+ /*return Err(TreeError::Background(
+ BackgroundErr::AlreadyAttached(*output_id, background.clone().unwrap())))*/
+ if let Some(view) = background.take() {
+ to_remove.insert(view);
+ }
+ *background = Some(bg);
}
},
_ => return Err(TreeError::UuidWrongType(*output_id,
vec![ContainerType::Output]))
}
}
+ for view in to_remove {
+ view.close();
+ }
Ok(())
}
}
