refactor(mac): use the shared subscriber push

Same as the KDE revision: notify_subscribers keeps the macOS override events (Monitor, AddSubscriberSocket, AddSubscriberSocketWithOptions, Theme, ReloadStaticConfiguration, WindowManager Show) and the registry statics and hands the push to komorebi_transport::notify_sockets. 40 lines removed from lib.rs. Behaviour-preserving; logs use the target komorebi::transport (D29).

Verified: macOS fake-CC cargo check --locked --target aarch64-apple-darwin --workspace --all-targets: 0 errors, no new warnings. Unit tests cannot run on Linux.
This commit is contained in:
LGUG2Z committed 2026-10-31 01:37:54 -07:00
1 parent 63c23ed1e7
commit b85827e6ca
1 file changed
+8 -33
+8 -33
View File
@@ -36,7 +36,6 @@ use regex::Regex;
use serde::Deserialize;
use serde::Serialize;
use std::collections::HashMap;
use std::io::Write;
use std::ops::Deref;
use std::os::unix::net::UnixStream;
use std::panic;
@@ -227,41 +226,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),
)?;
Ok(())
}