From 49a6dbdabbbdb71ffc99b5640bb0c975c7c2ce78 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sat, 31 Oct 2026 09:59:49 -0700 Subject: [PATCH] refactor(mac): name the Window set-frame operation set_rect, as the shared Backend does Renames Window::set_position(&Rect) to Window::set_rect (window.rs and its 9 callers in workspace.rs, window_manager.rs, scrolling.rs, settle.rs and macos_backend.rs). Body untouched: the direct path (set_point, set_size) or the animator, as before; nothing changes at runtime. The animator's own free function set_position, set_point and set_size stay as they are (they are the AX writes, not the Window operation). Verified: macOS fake-CC type-check (tools/fast-check) PASS. Not verified: cannot run or unit-test on Linux. --- komorebi-for-mac/komorebi/src/macos_backend.rs | 4 ++-- komorebi-for-mac/komorebi/src/scrolling.rs | 4 ++-- komorebi-for-mac/komorebi/src/settle.rs | 2 +- komorebi-for-mac/komorebi/src/window.rs | 10 +++++----- komorebi-for-mac/komorebi/src/window_manager.rs | 4 ++-- komorebi-for-mac/komorebi/src/workspace.rs | 4 ++-- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/komorebi-for-mac/komorebi/src/macos_backend.rs b/komorebi-for-mac/komorebi/src/macos_backend.rs index 3bef4cd4..b1b32f0f 100644 --- a/komorebi-for-mac/komorebi/src/macos_backend.rs +++ b/komorebi-for-mac/komorebi/src/macos_backend.rs @@ -194,11 +194,11 @@ impl Backend for MacosBackend { } fn set_rect(&self, id: WindowId, rect: &Rect) -> Result<()> { - // `Window::set_position` writes directly (two Accessibility writes) or hands the move to + // `Window::set_rect` writes directly (two Accessibility writes) or hands the move to // the animator, depending on the animation settings; both are requests let window = self.lookup(id)?; window - .set_position(rect) + .set_rect(rect) .map_err(|e| Self::failed(id, &window, e)) } diff --git a/komorebi-for-mac/komorebi/src/scrolling.rs b/komorebi-for-mac/komorebi/src/scrolling.rs index a11ae9c3..c87bc504 100644 --- a/komorebi-for-mac/komorebi/src/scrolling.rs +++ b/komorebi-for-mac/komorebi/src/scrolling.rs @@ -303,7 +303,7 @@ impl Workspace { for window in container.windows_mut() { let result = match placement.visibility { Visibility::Visible => window - .set_position(&rect) + .set_rect(&rect) .map(|()| window.note_arrival(&rect, resized)), Visibility::Clipped => { // part of it is in view and the rest is past the edge of the screen, @@ -315,7 +315,7 @@ impl Workspace { } window - .set_position(&target) + .set_rect(&target) .map(|()| window.note_arrival(&target, resized)) } Visibility::OffLeft => { diff --git a/komorebi-for-mac/komorebi/src/settle.rs b/komorebi-for-mac/komorebi/src/settle.rs index 38294b3d..8c9fd60a 100644 --- a/komorebi-for-mac/komorebi/src/settle.rs +++ b/komorebi-for-mac/komorebi/src/settle.rs @@ -207,7 +207,7 @@ impl WindowManager { let _snapping = Snapping::end(); for (window, layout) in &off { - if let Err(error) = window.set_position(layout) { + if let Err(error) = window.set_rect(layout) { tracing::debug!( "live resize: could not send window {} again: {error}", window.id diff --git a/komorebi-for-mac/komorebi/src/window.rs b/komorebi-for-mac/komorebi/src/window.rs index de2ce50b..1b9b441b 100644 --- a/komorebi-for-mac/komorebi/src/window.rs +++ b/komorebi-for-mac/komorebi/src/window.rs @@ -917,7 +917,7 @@ impl Window { )) } - pub fn set_position(&self, rect: &Rect) -> Result<(), AccessibilityError> { + pub fn set_rect(&self, rect: &Rect) -> Result<(), AccessibilityError> { match snap() { Snap::Step(dragged) => return self.set_position_for_step(dragged, rect), Snap::End => { @@ -1204,7 +1204,7 @@ impl Window { let x = work_area.left + ((work_area.right - target_width) / 2); let y = work_area.top + ((work_area.bottom - target_height) / 2); - self.set_position(&Rect { + self.set_rect(&Rect { left: x, top: y, right: target_width, @@ -1255,7 +1255,7 @@ impl Window { // let anim_count = ANIMATION_MANAGER // .lock() // .count_in_progress(MovementRenderDispatcher::PREFIX); - // self.set_position(&new_rect, true)?; + // self.set_rect(&new_rect, true)?; // let hwnd = self.hwnd; // // Wait for the animation to finish before maximizing the window again, otherwise // // we would be maximizing the window on the current monitor anyway @@ -1274,11 +1274,11 @@ impl Window { // windows_api::WindowsApi::maximize_window(hwnd); // }); // } else { - // self.set_position(&new_rect, true)?; + // self.set_rect(&new_rect, true)?; // windows_api::WindowsApi::maximize_window(self.hwnd); // } // } else { - self.set_position(&new_rect)?; + self.set_rect(&new_rect)?; // } Ok(()) diff --git a/komorebi-for-mac/komorebi/src/window_manager.rs b/komorebi-for-mac/komorebi/src/window_manager.rs index 3fd668b8..c7e08c74 100644 --- a/komorebi-for-mac/komorebi/src/window_manager.rs +++ b/komorebi-for-mac/komorebi/src/window_manager.rs @@ -787,7 +787,7 @@ impl WindowManager { } } - window.set_position(&rect)?; + window.set_rect(&rect)?; if mouse_follows_focus { MacosApi::center_cursor_in_rect(&rect)?; @@ -1750,7 +1750,7 @@ impl WindowManager { } } - window.set_position(&rect)?; + window.set_rect(&rect)?; if mouse_follows_focus { MacosApi::center_cursor_in_rect(&rect)?; diff --git a/komorebi-for-mac/komorebi/src/workspace.rs b/komorebi-for-mac/komorebi/src/workspace.rs index a66674d1..4f93785b 100644 --- a/komorebi-for-mac/komorebi/src/workspace.rs +++ b/komorebi-for-mac/komorebi/src/workspace.rs @@ -1476,7 +1476,7 @@ impl Workspace { adjusted_work_area.add_padding(container_padding); adjusted_work_area.add_padding(border_offset); adjusted_work_area.add_padding(border_width); - window.set_position(&adjusted_work_area)?; + window.set_rect(&adjusted_work_area)?; }; } else if !self.containers().is_empty() { if self.is_scrolling() { @@ -1503,7 +1503,7 @@ impl Workspace { layout.add_padding(border_width); for window in container.windows_mut() { - if let Err(error) = window.set_position(layout) { + if let Err(error) = window.set_rect(layout) { tracing::warn!("failed to set window position: {error}") } }