summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/bar_state.rs17
1 files changed, 3 insertions, 14 deletions
diff --git a/src/bar_state.rs b/src/bar_state.rs
index fc34102..8a2d8cf 100644
--- a/src/bar_state.rs
+++ b/src/bar_state.rs
@@ -221,20 +221,9 @@ impl BarState {
}
pub fn handle_events(&mut self) {
- // This is ugly, let's hope that some version of drain_filter() gets stabilized soon
- // https://github.com/rust-lang/rust/issues/43244
- let mut i = 0;
- while i != self.surfaces.len() {
- if self.surfaces[i].handle_events(
- &self.blocks,
- &mut self.blocks_cache,
- self.blocks_updated,
- ) {
- self.surfaces.remove(i);
- } else {
- i += 1;
- }
- }
+ self.surfaces.retain_mut(|surface| {
+ !surface.handle_events(&self.blocks, &mut self.blocks_cache, self.blocks_updated)
+ });
self.blocks_updated = false;
}
}