From 74652fb451b830f7f9e5cf8e15dc51723d313c7d Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sat, 31 Oct 2026 10:29:53 -0700 Subject: [PATCH] refactor(windows): process_command.rs reads frames through backend().frame() Every WindowsApi::window_rect(hwnd) in process_command.rs becomes backend().frame(WindowId::from_hwnd(hwnd)). WindowsBackend::frame is Window::window_rect, i.e. the same DWM call with the Win32 error kept; the callers' ?, ok(), unwrap_or_default() and is_ok_and() behave as before (only the error text can differ: a window that died meanwhile reports WindowGone). BEHAVIOUR: none intended; e2e gate needed: commands, resize. Verified: Windows clippy -D warnings via tools/fast-check PASS; e2e not run. --- komorebi/src/process_command.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index b123aadb..c7ec8c68 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -401,7 +401,8 @@ impl WindowManager { } SocketMessage::ForceFocus => { let focused_window = self.focused_window()?; - let focused_window_rect = WindowsApi::window_rect(focused_window.hwnd)?; + let focused_window_rect = + backend().frame(WindowId::from_hwnd(focused_window.hwnd))?; WindowsApi::center_cursor_in_rect(&focused_window_rect)?; WindowsApi::left_click(); } @@ -1299,7 +1300,9 @@ impl WindowManager { // Sort by window area window_idx_pairs.sort_by_key(|(_, w)| { - let rect = WindowsApi::window_rect(w.hwnd).unwrap_or_default(); + let rect = backend() + .frame(WindowId::from_hwnd(w.hwnd)) + .unwrap_or_default(); rect.right * rect.bottom }); window_idx_pairs.reverse(); @@ -1363,7 +1366,9 @@ impl WindowManager { // Sort by window area window_idx_pairs.sort_by_key(|w| { - let rect = WindowsApi::window_rect(w.hwnd).unwrap_or_default(); + let rect = backend() + .frame(WindowId::from_hwnd(w.hwnd)) + .unwrap_or_default(); rect.right * rect.bottom });