From 1aa9c580de4f295729413edb4afd99f0daaddea0 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sat, 31 Oct 2026 18:53:57 -0700 Subject: [PATCH] refactor(mac): the lock and unlock arms call komorebi-core The same two arms as on KDE call komorebi_core::set_container_locked, and WindowManager implements ContainerCommandHost. No behaviour change. Verified: fake-CC cargo clippy -p komorebi-macos ... --all-targets -D warnings: PASS (type-check only). Not run: the macOS tests (the Mac Mini). --- .../komorebi/src/process_command.rs | 50 ++++++++----------- 1 file changed, 20 insertions(+), 30 deletions(-) diff --git a/komorebi-for-mac/komorebi/src/process_command.rs b/komorebi-for-mac/komorebi/src/process_command.rs index 1d02ccaf..da3e5181 100644 --- a/komorebi-for-mac/komorebi/src/process_command.rs +++ b/komorebi-for-mac/komorebi/src/process_command.rs @@ -542,40 +542,24 @@ impl WindowManager { monitor_idx, workspace_idx, container_idx, - ) => { - let monitor = self - .monitors_mut() - .get_mut(monitor_idx) - .ok_or_eyre("no monitor at the given index")?; - - let workspace = monitor - .workspaces_mut() - .get_mut(workspace_idx) - .ok_or_eyre("no workspace at the given index")?; - - if let Some(container) = workspace.containers_mut().get_mut(container_idx) { - container.locked = true; - } - } + ) => komorebi_core::set_container_locked( + self, + monitor_idx, + workspace_idx, + container_idx, + true, + )?, SocketMessage::UnlockMonitorWorkspaceContainer( monitor_idx, workspace_idx, container_idx, - ) => { - let monitor = self - .monitors_mut() - .get_mut(monitor_idx) - .ok_or_eyre("no monitor at the given index")?; - - let workspace = monitor - .workspaces_mut() - .get_mut(workspace_idx) - .ok_or_eyre("no workspace at the given index")?; - - if let Some(container) = workspace.containers_mut().get_mut(container_idx) { - container.locked = false; - } - } + ) => komorebi_core::set_container_locked( + self, + monitor_idx, + workspace_idx, + container_idx, + false, + )?, SocketMessage::FlipLayout(layout_flip) => self.flip_layout(layout_flip)?, SocketMessage::ChangeLayout(layout) => self.change_workspace_layout_default(layout)?, SocketMessage::CycleLayout(direction) => self.cycle_layout(direction)?, @@ -1817,6 +1801,12 @@ impl komorebi_core::MonitorCommandHost for WindowManager { } } +impl komorebi_core::ContainerCommandHost for WindowManager { + fn monitors_mut(&mut self) -> &mut std::collections::VecDeque { + WindowManager::monitors_mut(self) + } +} + #[cfg(test)] mod tests { use crate::SocketMessage;