Skip to content

GlazeWM is a tiling window manager for macOS and Windows inspired by i3wm.

feat: ensure the same window is not redrawn multiple times

Lars Bergera214af5c88c2
diff --git a/packages/wm/src/wm_state.rs b/packages/wm/src/wm_state.rs
index fd5c8074..329d4282 100644
--- a/packages/wm/src/wm_state.rs
+++ b/packages/wm/src/wm_state.rs
@@ -1,4 +1,4 @@
-use std::time::Instant;
+use std::{collections::HashSet, time::Instant};
use anyhow::Context;
use tokio::sync::mpsc::{self};
@@ -251,9 +251,10 @@ impl WmState {
///
/// When redrawing after a command that changes a window's type (e.g.
/// tiling -> floating), the original detached window might still be
- /// queued for a redraw and should be ignored.
+ /// queued for a redraw and should be filtered out.
pub fn windows_to_redraw(&self) -> Vec<WindowContainer> {
- // TODO: Get unique windows.
+ let mut unique_ids = HashSet::new();
+
self
.pending_sync
.containers_to_redraw
@@ -261,6 +262,7 @@ impl WmState {
.flat_map(|container| container.self_and_descendants())
.filter(|container| !container.is_detached())
.filter_map(|container| container.try_into().ok())
+ .filter(|window: &WindowContainer| unique_ids.insert(window.id()))
.collect()
}