From 69680b423840bc0c54b3b6f948adff7d1a25918f Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Tue, 21 May 2024 08:20:14 -0700 Subject: [PATCH] fix(stackbar): destroy stackbars on ws change This commit ensures that whenever we receive a stackbar_manager::Notification any stackbars not associated with the current workspace on each monitor are destroyed. fix #838 --- komorebi/src/stackbar_manager/mod.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/komorebi/src/stackbar_manager/mod.rs b/komorebi/src/stackbar_manager/mod.rs index 1cf3d13f..e7cbe2fe 100644 --- a/komorebi/src/stackbar_manager/mod.rs +++ b/komorebi/src/stackbar_manager/mod.rs @@ -136,6 +136,27 @@ pub fn handle_notifications(wm: Arc>) -> color_eyre::Result continue 'receiver; } + // Destroy any stackbars not associated with the focused workspace + let container_ids = ws + .containers() + .iter() + .map(|c| c.id().clone()) + .collect::>(); + + let mut to_remove = vec![]; + for (id, stackbar) in stackbars.iter() { + if stackbars_monitors.get(id).copied().unwrap_or_default() == monitor_idx + && !container_ids.contains(id) + { + stackbar.destroy()?; + to_remove.push(id.clone()); + } + } + + for id in &to_remove { + stackbars.remove(id); + } + let container_padding = ws .container_padding() .unwrap_or_else(|| DEFAULT_CONTAINER_PADDING.load_consume());