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).
This commit is contained in:
LGUG2Z committed 2026-10-31 01:37:54 -07:00
1 parent b85827e6ca
commit 8806a410d8
1 file changed
+8 -32
+8 -32
View File
@@ -367,41 +367,17 @@ pub fn notify_subscribers(
);
let notification = &serde_json::to_string(&notification)?;
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();