From 8806a410d8d5dd0b96a990acb04d0e611ce7e9f0 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Fri, 30 Oct 2026 22:25:13 -0700 Subject: [PATCH] refactor(windows): use the shared subscriber push notify_subscribers keeps the Windows override events (TitleUpdate, Uncloak and Show, no Monitor), the registry statics and the whole named-pipe part (SUBSCRIPTION_PIPES, error codes 2 and 232), and hands the socket push to komorebi_transport::notify_sockets with uds_windows::UnixStream::connect. Both locks are still held to the end of the function and the early return on a write error still skips the pipes. 33 lines removed from lib.rs. Behaviour-preserving; logs of the socket part use the target komorebi::transport (D29). Verified: nix develop --command cargo clippy --workspace --locked --all-targets -- -D warnings (x86_64-pc-windows-msvc): finished, no warnings or errors. Not verified: Windows tests and scenarios (subscribers are exercised by the bar and the scenarios). --- komorebi/src/lib.rs | 40 ++++++++-------------------------------- 1 file changed, 8 insertions(+), 32 deletions(-) diff --git a/komorebi/src/lib.rs b/komorebi/src/lib.rs index e5dac5c7..428e39ee 100644 --- a/komorebi/src/lib.rs +++ b/komorebi/src/lib.rs @@ -367,41 +367,17 @@ pub fn notify_subscribers( ); let notification = &serde_json::to_string(¬ification)?; - let mut stale_sockets = vec![]; let mut sockets = SUBSCRIPTION_SOCKETS.lock(); let options = SUBSCRIPTION_SOCKET_OPTIONS.lock(); - for (socket, path) in &mut *sockets { - let apply_state_filter = (*options) - .get(socket) - .copied() - .unwrap_or_default() - .filter_state_changes; - - if !apply_state_filter || state_has_been_modified || is_override_event { - match UnixStream::connect(path) { - Ok(mut stream) => { - tracing::debug!("pushed notification to subscriber: {socket}"); - stream.write_all(notification.as_bytes())?; - } - Err(_) => { - stale_sockets.push(socket.clone()); - } - } - } - } - - for socket in stale_sockets { - tracing::warn!("removing stale subscription: {socket}"); - sockets.remove(&socket); - let socket_path = DATA_DIR.join(socket); - if let Err(error) = std::fs::remove_file(&socket_path) { - tracing::error!( - "could not remove stale subscriber socket file at {}: {error}", - socket_path.display() - ) - } - } + komorebi_transport::notify_sockets( + notification, + &mut sockets, + &options, + state_has_been_modified || is_override_event, + &DATA_DIR, + |path| UnixStream::connect(path), + )?; let mut stale_pipes = vec![]; let mut pipes = SUBSCRIPTION_PIPES.lock();