refactor(windows): give Window the shared operation names

Window already had focus, raise, hide, restore, minimize and close under
the names of the shared Backend trait (docs/dev/seam.md section 2). Add
the four that were missing as thin delegates: set_rect (set_position with
top = false), alive (is_window), window_rect (WindowsApi::window_rect) and
unminimize (WindowsApi::restore_window). No call site changes; the
unused-by-the-daemon WindowsBackend now calls the new names.

Not a behaviour change. Verified: Windows clippy -D warnings via
tools/fast-check PASS.
This commit is contained in:
LGUG2Z committed 2026-10-31 10:14:06 -07:00
1 parent 8f37b9aea6
commit 69073153d9
2 files changed
+29 -4

No files matched your search

+25
View File
@@ -725,6 +725,31 @@ impl Window {
WindowsApi::is_window(self.hwnd)
}
// The operation names of the shared `komorebi_backend::Backend` (docs/dev/seam.md, section 2).
// `set_rect`, `alive`, `window_rect` and `unminimize` only delegate; `focus`, `raise`, `hide`,
// `restore`, `minimize` and `close` above already carry the shared name.
/// Set frame: `set_position` without raising the window to the front.
pub fn set_rect(self, rect: &Rect) -> eyre::Result<()> {
self.set_position(rect, false)
}
/// Alive check: Windows still has the window (`IsWindow`).
pub fn alive(self) -> bool {
self.is_window()
}
/// Frame query: the visible bounds (without the shadow), see `WindowsApi::window_rect`.
pub fn window_rect(self) -> eyre::Result<Rect> {
WindowsApi::window_rect(self.hwnd)
}
/// Windows has no unminimize of its own: `SW_SHOWNOACTIVATE`, as `restore` ends in for the
/// `Hide` and `Minimize` hiding behaviours, without the `HIDDEN_HWNDS` and border bookkeeping.
pub fn unminimize(self) {
WindowsApi::restore_window(self.hwnd);
}
pub fn remove_title_bar(self) -> eyre::Result<()> {
let mut style = self.style()?;
style.remove(WindowStyle::CAPTION);
+4 -4
View File
@@ -54,7 +54,7 @@ fn platform(report: eyre::Report) -> Error {
impl WindowsBackend {
fn info(window: Window) -> Option<WindowInfo> {
let hwnd = window.hwnd;
if !WindowsApi::is_window(hwnd) {
if !window.alive() {
return None;
}
@@ -63,7 +63,7 @@ impl WindowsBackend {
pid: i32::try_from(window.process_id()).unwrap_or_default(),
// Windows reports the visible bounds (without the shadow); an error leaves the
// default, which a caller cannot tell from a window at the origin: see seam.md 9
rect: WindowsApi::window_rect(hwnd).unwrap_or_default(),
rect: window.window_rect().unwrap_or_default(),
minimized: window.is_miminized(),
alive: true,
title: window.title().ok(),
@@ -136,7 +136,7 @@ impl Backend for WindowsBackend {
// contract does not have: it is false here and a caller raises with `raise`.
// `Window::set_position` also keeps its animation, slide-in and live-resize guards
// and skips the write when the frame is already right: see seam.md 9.
window.set_position(rect, false).map_err(|e| failed(id, e))
window.set_rect(rect).map_err(|e| failed(id, e))
}
fn focus(&self, id: WindowId, mouse_follows_focus: bool) -> Result<()> {
@@ -172,7 +172,7 @@ impl Backend for WindowsBackend {
// for the `Hide` and `Minimize` hiding behaviours, and without the HIDDEN_HWNDS and
// border bookkeeping of `Window::restore`
live(id)?;
WindowsApi::restore_window(id.to_hwnd());
Window::from(id.to_hwnd()).unminimize();
Ok(())
}