diff --git a/komorebi/src/border_manager/mod.rs b/komorebi/src/border_manager/mod.rs index e84d1316..feb7a7b8 100644 --- a/komorebi/src/border_manager/mod.rs +++ b/komorebi/src/border_manager/mod.rs @@ -59,7 +59,7 @@ pub struct Notification; static CHANNEL: OnceLock<(Sender, Receiver)> = OnceLock::new(); pub fn channel() -> &'static (Sender, Receiver) { - CHANNEL.get_or_init(crossbeam_channel::unbounded) + CHANNEL.get_or_init(|| crossbeam_channel::bounded(5)) } pub fn event_tx() -> Sender { @@ -129,11 +129,16 @@ pub fn handle_notifications(wm: Arc>) -> color_eyre::Result // Check the wm state every time we receive a notification let state = wm.lock(); + let is_paused = state.is_paused; + let focused_monitor_idx = state.focused_monitor_idx(); + let monitors = state.monitors.elements().clone(); + let pending_move_op = state.pending_move_op.clone(); + drop(state); // If borders are disabled if !BORDER_ENABLED.load_consume() // Or if the wm is paused - || state.is_paused + || is_paused // Or if we are handling an alt-tab across workspaces || ALT_TAB_HWND.load().is_some() { @@ -146,9 +151,7 @@ pub fn handle_notifications(wm: Arc>) -> color_eyre::Result continue 'receiver; } - let focused_monitor_idx = state.focused_monitor_idx(); - - 'monitors: for (monitor_idx, m) in state.monitors.elements().iter().enumerate() { + 'monitors: for (monitor_idx, m) in monitors.iter().enumerate() { // Only operate on the focused workspace of each monitor if let Some(ws) = m.focused_workspace() { // Workspaces with tiling disabled don't have borders @@ -215,6 +218,7 @@ pub fn handle_notifications(wm: Arc>) -> color_eyre::Result for id in &to_remove { borders.remove(id); } + continue 'monitors; } @@ -261,7 +265,7 @@ pub fn handle_notifications(wm: Arc>) -> color_eyre::Result for (idx, c) in ws.containers().iter().enumerate() { // Update border when moving or resizing with mouse - if state.pending_move_op.is_some() && idx == ws.focused_container_idx() { + if pending_move_op.is_some() && idx == ws.focused_container_idx() { let restore_z_order = *Z_ORDER.lock(); *Z_ORDER.lock() = ZOrder::TopMost; diff --git a/komorebi/src/stackbar_manager/mod.rs b/komorebi/src/stackbar_manager/mod.rs index e7cbe2fe..f4e0655f 100644 --- a/komorebi/src/stackbar_manager/mod.rs +++ b/komorebi/src/stackbar_manager/mod.rs @@ -40,7 +40,7 @@ pub struct Notification; static CHANNEL: OnceLock<(Sender, Receiver)> = OnceLock::new(); pub fn channel() -> &'static (Sender, Receiver) { - CHANNEL.get_or_init(crossbeam_channel::unbounded) + CHANNEL.get_or_init(|| crossbeam_channel::bounded(5)) } pub fn event_tx() -> Sender { diff --git a/komorebi/src/transparency_manager.rs b/komorebi/src/transparency_manager.rs index bc7841bf..8d9c5f0c 100644 --- a/komorebi/src/transparency_manager.rs +++ b/komorebi/src/transparency_manager.rs @@ -29,7 +29,7 @@ pub fn known_hwnds() -> Vec { } pub fn channel() -> &'static (Sender, Receiver) { - CHANNEL.get_or_init(crossbeam_channel::unbounded) + CHANNEL.get_or_init(|| crossbeam_channel::bounded(5)) } pub fn event_tx() -> Sender { diff --git a/komorebi/src/winevent_listener.rs b/komorebi/src/winevent_listener.rs index 4b9220cf..f74a7ddf 100644 --- a/komorebi/src/winevent_listener.rs +++ b/komorebi/src/winevent_listener.rs @@ -50,7 +50,7 @@ pub fn start() { } fn channel() -> &'static (Sender, Receiver) { - CHANNEL.get_or_init(crossbeam_channel::unbounded) + CHANNEL.get_or_init(|| crossbeam_channel::bounded(5)) } pub fn event_tx() -> Sender {