refactor(windows): centre cursor, focus-follows-mouse off and unminimize go through backend()

window_manager.rs: three WindowsApi::center_cursor_in_rect calls become
backend().center_cursor_in(..) and WindowsApi::disable_focus_follows_mouse
becomes backend().set_focus_follows_mouse(false); workspace.rs: the
WindowsApi::restore_window that unmaximizes a window becomes
backend().unminimize(..) (the same ShowWindow call, after an IsWindow check).
backend-switch.md now lists every WindowsApi call left in window_manager,
workspace and monitor and why each cannot be switched without changing an
error, a default or a flag (foreground_window, cursor_pos, focus on the
desktop window, position_window flags, start-up enumeration, monitor fields).

BEHAVIOUR: a dead window is skipped by the unminimize. e2e gate needed:
commands, focus_follows_mouse, maximizing, workspaces. Verified: Windows
clippy -D warnings via tools/fast-check PASS; e2e not run.
This commit is contained in:
LGUG2Z committed 2026-10-31 11:20:32 -07:00
1 parent 9daa4d726a
commit 18ca78196f
3 files changed
+22 -5

No files matched your search

+17
View File
@@ -41,3 +41,20 @@ use `?` or ignore the result; none inspects the error. `frame` is the exception:
| `cursor_pos` | `Result<POINT>` vs `Option<(i32, i32)>`; callers `?` it | same: a `Result` return |
| `monitors` / `window` | `monitors()` rebuilds `MonitorInfo` and drops the `Monitor` fields the daemon needs (device id, serial, device, work-area offsets); `window()` asks title, class, exe, path | the daemon-side `Monitor` fields in `MonitorInfo` (or a platform extension), and for step 9 the monitor model moving to the core |
| `monitor_from_point` | never `None` on Windows (`MONITOR_DEFAULTTONEAREST`), `None` outside every monitor on KDE and macOS | an explicit "nearest" flag or two methods |
## What is left in `window_manager.rs`, `workspace.rs`, `monitor.rs` (checked call by call)
Switched in the last batch: `center_cursor_in_rect` (3, window_manager), `disable_focus_follows_mouse` (1),
`restore_window` as `unminimize` (1, workspace). The rest names `WindowsApi` for a reason the trait does not
cover yet:
| Call (sites) | Why it stays |
|---|---|
| `foreground_window` (10 in window_manager, 3 workspace, 1 monitor) | `Result<isize>`, a null handle is an `Err` the callers `?` on; trait has `Option<WindowId>` |
| `cursor_pos`, `window_at_cursor_pos`, `monitor_from_window`, `monitor_from_point` | `Result`/never-`None` semantics, see the table above; `window_at_cursor_pos` and `monitor_from_window` have no trait equivalent |
| `raise_and_focus_window(desktop_window)` (4) | `Backend::focus` is `Window::focus`, which skips when the window is already foreground and defers while it slides in; the direct call always raises and focuses |
| `position_window(hwnd, rect, false, true)` (2) | a different flag combination than `set_rect` (`top = false`, the second flag is the layered/shadow handling), not expressible |
| `load_monitor_information`, `load_workspace_information` | start-up enumeration into a `WindowManager`; seam.md 9: `windows()` cannot match the core's filter |
| `monitor(hmonitor)`, `monitor_rects`, `monitors_have_same_dpi` | the `Monitor` fields (device id, DPI) the trait's `MonitorInfo` drops |
| `set_wallpaper` | wallpaper stays KDE-only in the trait (D36) |
| `focus_follows_mouse` (query) | the trait has the setter only |
+4 -4
View File
@@ -1147,7 +1147,7 @@ impl WindowManager {
let desktop_window = Window::from(WindowsApi::desktop_window()?);
let rect = self.focused_monitor_size()?;
WindowsApi::center_cursor_in_rect(&rect)?;
backend().center_cursor_in(&rect)?;
match WindowsApi::raise_and_focus_window(desktop_window.hwnd) {
Ok(()) => {}
@@ -1275,7 +1275,7 @@ impl WindowManager {
WindowsApi::position_window(window.hwnd, &rect, false, true)?;
if mouse_follows_focus {
WindowsApi::center_cursor_in_rect(&rect)?;
backend().center_cursor_in(&rect)?;
}
break;
@@ -1450,7 +1450,7 @@ impl WindowManager {
AnimationEngine::wait_for_all_animations();
if WindowsApi::focus_follows_mouse()? {
WindowsApi::disable_focus_follows_mouse()?;
backend().set_focus_follows_mouse(false)?;
}
let sockets = SUBSCRIPTION_SOCKETS.lock();
@@ -2425,7 +2425,7 @@ impl WindowManager {
WindowsApi::position_window(window.hwnd, &rect, false, true)?;
if mouse_follows_focus {
WindowsApi::center_cursor_in_rect(&rect)?;
backend().center_cursor_in(&rect)?;
}
break;
+1 -1
View File
@@ -835,7 +835,7 @@ impl Workspace {
// If a window has been unmaximized via toggle-maximize, this block
// will make sure that it is unmaximized via restore_window
if window.is_maximized() && !managed_maximized_window {
WindowsApi::restore_window(window.hwnd);
let _ = backend().unminimize(WindowId::from_hwnd(window.hwnd));
}
}
if hidden.get(i).copied().unwrap_or_default() {