From c2ca6847a93899df99dac56a7f2146b280daedf4 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sat, 31 Oct 2026 13:39:04 -0700 Subject: [PATCH] refactor(mac): Window hide, hide_on, hide_scrolling, restore, minimize and unminimize take &self None of them mutated the window; they read the element and write through Accessibility, so &mut self only forced callers to hold a mutable binding. The shared ContainerWindow operations take &self (a stack member is hidden through a shared reference), so the macOS impl needs these as &self. Six callers lose a now-unneeded mut. No behaviour change. Verified: macOS fake-CC type-check (tools/fast-check) PASS with no new warning. Verified on the Mini: not yet. --- komorebi-for-mac/komorebi/src/macos_backend.rs | 8 ++++---- komorebi-for-mac/komorebi/src/process_event.rs | 2 +- komorebi-for-mac/komorebi/src/window.rs | 12 ++++++------ komorebi-for-mac/komorebi/src/window_manager.rs | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/komorebi-for-mac/komorebi/src/macos_backend.rs b/komorebi-for-mac/komorebi/src/macos_backend.rs index ae73aef9..633c55d8 100644 --- a/komorebi-for-mac/komorebi/src/macos_backend.rs +++ b/komorebi-for-mac/komorebi/src/macos_backend.rs @@ -211,24 +211,24 @@ impl Backend for MacosBackend { fn hide(&self, id: WindowId) -> Result<()> { // a sliver in a corner of the display, observable by the app and the user - let mut window = self.lookup(id)?; + let window = self.lookup(id)?; window .hide(self.hiding_position) .map_err(|e| Self::failed(id, &window, e)) } fn restore(&self, id: WindowId) -> Result<()> { - let mut window = self.lookup(id)?; + let window = self.lookup(id)?; window.restore().map_err(|e| Self::failed(id, &window, e)) } fn minimize(&self, id: WindowId) -> Result<()> { - let mut window = self.lookup(id)?; + let window = self.lookup(id)?; window.minimize().map_err(|e| Self::failed(id, &window, e)) } fn unminimize(&self, id: WindowId) -> Result<()> { - let mut window = self.lookup(id)?; + let window = self.lookup(id)?; window .unminimize() .map_err(|e| Self::failed(id, &window, e)) diff --git a/komorebi-for-mac/komorebi/src/process_event.rs b/komorebi-for-mac/komorebi/src/process_event.rs index 0a03bcd5..2a86faa9 100644 --- a/komorebi-for-mac/komorebi/src/process_event.rs +++ b/komorebi-for-mac/komorebi/src/process_event.rs @@ -612,7 +612,7 @@ impl WindowManager { if create && !tabbed_window && let Some(element) = window_element - && let Ok(mut window) = Window::new(element, application.clone()) + && let Ok(window) = Window::new(element, application.clone()) { window.observe(&self.run_loop, None)?; let behaviour = self diff --git a/komorebi-for-mac/komorebi/src/window.rs b/komorebi-for-mac/komorebi/src/window.rs index 595e6702..14330ae4 100644 --- a/komorebi-for-mac/komorebi/src/window.rs +++ b/komorebi-for-mac/komorebi/src/window.rs @@ -639,7 +639,7 @@ impl Window { /// edge of a display is not always on the display that the lookup by position finds. #[tracing::instrument(skip_all)] pub fn hide( - &mut self, + &self, hiding_position: WindowHidingPosition, ) -> Result<(), AccessibilityError> { self.hide_on(hiding_position, None) @@ -653,7 +653,7 @@ impl Window { /// it is not given it is looked up from where the window is. #[tracing::instrument(skip_all)] pub fn hide_on( - &mut self, + &self, hiding_position: WindowHidingPosition, screen: Option, ) -> Result<(), AccessibilityError> { @@ -715,7 +715,7 @@ impl Window { /// of the screen instead, as with [`Window::hide`]. #[tracing::instrument(skip_all)] pub fn hide_scrolling( - &mut self, + &self, hiding_position: WindowHidingPosition, screen: Option, ) -> Result<(), AccessibilityError> { @@ -836,13 +836,13 @@ impl Window { .is_some_and(|b| b.as_bool()) } - pub fn minimize(&mut self) -> Result<(), AccessibilityError> { + pub fn minimize(&self) -> Result<(), AccessibilityError> { let cf_boolean = CFBoolean::new(true); let value = &**cf_boolean; AccessibilityApi::set_attribute_cf_value(&self.element, kAXMinimizedAttribute, value) } - pub fn unminimize(&mut self) -> Result<(), AccessibilityError> { + pub fn unminimize(&self) -> Result<(), AccessibilityError> { let cf_boolean = CFBoolean::new(false); let value = &**cf_boolean; AccessibilityApi::set_attribute_cf_value(&self.element, kAXMinimizedAttribute, value) @@ -854,7 +854,7 @@ impl Window { } #[tracing::instrument(skip_all)] - pub fn restore(&mut self) -> Result<(), AccessibilityError> { + pub fn restore(&self) -> Result<(), AccessibilityError> { // waiting for what is on its way to the window is not something to do with a lock held animator::take_over(self.id); PARKED_WINDOWS.lock().remove(&self.id); diff --git a/komorebi-for-mac/komorebi/src/window_manager.rs b/komorebi-for-mac/komorebi/src/window_manager.rs index e9dc083b..b39db0a7 100644 --- a/komorebi-for-mac/komorebi/src/window_manager.rs +++ b/komorebi-for-mac/komorebi/src/window_manager.rs @@ -3162,7 +3162,7 @@ impl WindowManager { .get_mut(op.origin_workspace_idx) .ok_or_eyre("there is no workspace with that index")?; - let mut window = origin_workspace.remove_window(op.window_id)?; + let window = origin_workspace.remove_window(op.window_id)?; // If it is a floating window move it to the target area if op.floating {