Monitor.id was an isize HMONITOR; it is now komorebi_backend::MonitorId (the
type WindowsBackend::monitors already returned). A serde adapter
(hmonitor_json) writes it with serialize_i64(to_hmonitor()) and reads an isize
through from_hmonitor, bit for bit, so the JSON is the same plain number as
before (including negative handles); the schemars schema is declared as isize.
serial_number_id was already Option<String> (the shared shape), so it is
unchanged. monitor::new / Monitor::new keep an isize parameter (every caller
passes an HMONITOR); the 12 uses that need the raw handle call
.to_hmonitor() (WindowsApi::monitor, wallpaper, DPI, zoomed checks, ids
compared with monitor_from_window/point). MonitorInformation.id stays isize.
BEHAVIOUR (JSON-identical by construction, not proven by running): the new
unit tests of the previous revision pin the JSON against a real capture,
but the Windows crate's tests cannot run on this host. Gate needed: any
e2e scenario that reads komorebic state or saves/loads it, and monitor
reconciliation / unknown_monitor. Verified: Windows clippy -D warnings via
tools/fast-check PASS.
Three unit tests in monitor.rs: a Monitor read from the monitor object of a
real komorebic state capture (e2e/lib/tests/fixtures/kfw-tiled.json, its
workspaces emptied) serializes back to the same JSON value; id and
serial_number_id are plain JSON values for ids including isize::MAX, -1 and
isize::MIN; MonitorInformation has the six documented fields. They fix the
representation before the type of Monitor.id changes.
The komorebi crate is Windows-only, so these compile (clippy --all-targets,
PASS) but cannot run on this host: they have NOT been run. Not a behaviour
change.
Query, ReplaceConfiguration and BorderColour become answer_query(query, reply),
replace_configuration(config) and set_border_colour(kind, r, g, b). Bodies
moved unchanged. force_update_borders is a local of process_command: the
border colour arm sets it after calling the (infallible) method, and
replace_configuration returns whether it replaced the configuration, which
is exactly where the arm used to set it (Result<bool>, where kfde's returns
Result<()>).
Not a behaviour change. Verified: Windows clippy -D warnings via
tools/fast-check PASS.
EagerFocus, ResizeWindowAxis, FocusFollowsMouse and ToggleFocusFollowsMouse
become eager_focus(exe), resize_window_axis(axis, sizing),
focus_follows_mouse(implementation, enable) and
toggle_focus_follows_mouse(implementation). Bodies moved unchanged.
Not a behaviour change. Verified: Windows clippy -D warnings via
tools/fast-check PASS.
IgnoreRule, SessionFloatRule and LayoutRatios become add_ignore_rule(identifier,
id), add_session_float_rule() and set_layout_ratios(columns, rows), the names
kfde used. Bodies moved unchanged; each arm is one self.x(..)? call.
Not a behaviour change. Verified: Windows clippy -D warnings via
tools/fast-check PASS.
ToggleWorkspaceLayer, CycleFocusWorkspace, CycleFocusEmptyWorkspace,
CloseWorkspace, FocusLastWorkspace, FocusWorkspaceNumbers and
MoveContainerToLastWorkspace / SendContainerToLastWorkspace (one method with
a follow flag, as the 20-line arms differed only by true/false) become
pub fn toggle_workspace_layer, cycle_focus_workspace(direction),
cycle_focus_empty_workspace(direction), close_workspace, focus_last_workspace,
focus_workspace_numbers(idx) and move_container_to_last_workspace(follow) in
a second impl WindowManager block in process_command.rs. The arm bodies moved
unchanged (dedented, ending in Ok(())); each arm is now one self.x(..)? call.
Same names as kfde's table in docs/dev/core-model.md where the command is the
same (focus_last_workspace and focus_workspace_numbers are Windows names).
Not a behaviour change. Verified: Windows clippy -D warnings via
tools/fast-check PASS.
KDE's Container and the Windows one already have the same method set and
signatures (add_window(Window), hide, restore and load_focused_window return
nothing; the earlier backend() switches made hide/restore the same calls).
The last field-level difference was the visibility of windows: pub on KDE,
private here. Make it pub; the Ring accessors (windows(), windows_mut())
stay.
Not converged, on purpose: Window::exe() is eyre::Result<String> here and
Option<String> on KDE; it has 33 callers that use ? or Ok(..) patterns, so
changing it is its own revision (not mechanical in the container alone);
hwnd_from_exe (2 callers in workspace.rs) and the hwnd/WindowId parameter
types wait for the shared core.
Not a behaviour change. Verified: Windows clippy -D warnings via
tools/fast-check PASS.
docs/dev/backend-switch.md now has the table of what is switched (focus,
set_rect with top = false, frame reads, plain hide/restore, minimize,
close, raise, maximize), what is left in the Windows crate on purpose
(top = true set_position, the *_with_border calls, transition and ghost
machinery, set_opacity: border and animation subsystems are platform-owned,
seam.md rule 5), and, for each query not switched (foreground_window,
cursor_pos, monitors, window, monitor_from_point), what the trait would
need so step 9 can decide.
Docs only.
The five window.maximize() / unmaximize() calls in workspace.rs become
let _ = backend().maximize(id, true/false). The trait already has the
capability query (Backend::supports(Capability::Maximize), true on
Windows), so no trait change; the Windows daemon does not need to ask, the
shared core will. WindowsBackend::maximize runs Window::maximize /
unmaximize, which keep the HIDDEN_HWNDS bookkeeping. set_opacity is NOT
switched: the adapter's set_opacity is the plain write, while
Window::transparent/opaque take the alpha from the transparency manager and
animate.
BEHAVIOUR: a dead window is skipped (IsWindow first). e2e gate needed:
maximizing, commands, workspaces. Verified: Windows clippy -D warnings via
tools/fast-check PASS; e2e not run.
Every WindowsApi::window_rect(hwnd) in window_manager.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, layouts, workspaces, stacking. Verified: Windows clippy
-D warnings via tools/fast-check PASS; e2e not run.
Every WindowsApi::window_rect(hwnd) in border_manager/border.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: borders. Verified: Windows clippy
-D warnings via tools/fast-check PASS; e2e not run.
Every WindowsApi::window_rect(hwnd) in process_event.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, lifecycle, resize, move. Verified: Windows clippy
-D warnings via tools/fast-check PASS; e2e not run.
Every WindowsApi::window_rect(hwnd) in animation/ghost.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: animation scenarios. Verified: Windows clippy
-D warnings via tools/fast-check PASS; e2e not run.
Every WindowsApi::window_rect(hwnd) in border_manager/mod.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: borders. Verified: Windows clippy
-D warnings via tools/fast-check PASS; e2e not run.
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.
Every WindowsApi::window_rect(hwnd) in animation/ghost_dispatcher.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: animation scenarios. Verified: Windows clippy
-D warnings via tools/fast-check PASS; e2e not run.
Every WindowsApi::window_rect(hwnd) in scrolling.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: scrolling. Verified: Windows clippy
-D warnings via tools/fast-check PASS; e2e not run.
Every WindowsApi::window_rect(hwnd) in pan.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: scrolling pan. Verified: Windows clippy
-D warnings via tools/fast-check PASS; e2e not run.
Every WindowsApi::window_rect(hwnd) in live_resize.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: resize. Verified: Windows clippy
-D warnings via tools/fast-check PASS; e2e not run.
Every WindowsApi::window_rect(hwnd) in animation/snapshot.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: animation scenarios, workspaces. Verified: Windows clippy
-D warnings via tools/fast-check PASS; e2e not run.
Every WindowsApi::window_rect(hwnd) in stackbar_manager/stackbar.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: stacking. Verified: Windows clippy
-D warnings via tools/fast-check PASS; e2e not run.
Every WindowsApi::window_rect(hwnd) in stackbar_manager/mod.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: stacking, layouts. Verified: Windows clippy
-D warnings via tools/fast-check PASS; e2e not run.
process_command (close and minimize of the foreground window, four raise
calls) and monitor_reconciliator (four minimize calls) now call
backend().close/minimize/raise. WindowsBackend runs Window::close,
minimize and raise unchanged (minimize still leaves komorebi-bar alone).
docs/dev/backend-switch.md now holds the full table of what is switched
and what is left, including why the queries (window_rect,
foreground_window, cursor_pos, monitors) were NOT switched: each would drop
an error that callers use or report, or fabricate a default.
BEHAVIOUR: a dead window is skipped by an IsWindow check first; minimize
results are ignored as before. e2e gate needed: commands, monitor
reconciliation (monitor_reconciliator), lifecycle. Verified: Windows clippy
-D warnings via tools/fast-check PASS; e2e not run.
The 23 window.hide() and window.restore() calls (container, workspace,
monitor, process_command, process_event, window_manager) become
let _ = backend().hide(..) / restore(..): WindowsBackend runs Window::hide
and Window::restore, so hiding behaviour (cloak, hide, minimize), border
and HIDDEN_HWNDS bookkeeping are the same. Not switched: hide_with_border
and restore_with_border (the shared trait has no border flag), the
animation transition and ghost dispatcher calls (they run inside the
slide-in machinery), minimize, close, raise and maximize (to follow).
BEHAVIOUR: a window that is already gone is skipped (IsWindow first), so it
is no longer added to HIDDEN_HWNDS or shown; the result is ignored as
before. e2e gate needed: commands, workspaces, stacking, lifecycle_hidden,
minimize/monitor scenarios. Verified: Windows clippy -D warnings via
tools/fast-check PASS; e2e not run.
The two Window::set_position(rect, false) call sites (the workspace
layout update in workspace.rs and the stackbar tab click) now call
backend().set_rect(..), which is Window::set_rect = set_position(rect,
false): the animation, slide-in and live-resize guards are the same.
Not switched: the top = true callers (window.rs move_to_area/center,
workspace.rs maximize area), since the shared set_rect has no top flag, and
all window_rect reads: the shared window_rect is built on window(id), which
asks title, class, exe and path of every window, returns None instead of the
Win32 error and defaults on failure; the 60 call sites rely on Err or
unwrap_or_default, so they stay on WindowsApi::window_rect until the trait
or the adapter has a cheap frame query.
BEHAVIOUR: a dead window fails early with Error::WindowGone, and one
extra IsWindow call per write. e2e gate needed: commands, resize, layouts,
stacking, scrolling, workspaces. Verified: Windows clippy -D warnings via
tools/fast-check PASS; e2e not run.
Switch the 40 Window::focus(mouse_follows)? call sites in process_event,
process_command, workspace, window_manager, focus_manager and the
stackbar click to backend().focus(WindowId::from_hwnd(..), mouse_follows).
WindowsBackend::focus runs Window::focus, so the deferral while a window
slides in, the already-foreground shortcut and the cursor centring are
unchanged. animation/transition.rs:534 stays on Window::focus (it is the
code Window::focus defers to). docs/dev/backend-switch.md records what is
switched.
BEHAVIOUR: a dead window now fails early with Error::WindowGone (before:
the Win32 error from raise_and_focus_window) and a failed focus of a window
that died meanwhile reports WindowGone; every caller uses ? or ignores the
result. e2e gate needed: commands, focus, focus_follows_mouse, stacking,
workspaces, lifecycle. Verified: Windows clippy -D warnings via
tools/fast-check PASS; e2e not run.
A static WindowsBackend behind backend() -> &'static dyn Backend, the way
KDE spells it. Nothing calls it yet; the next revisions switch call sites
one cluster at a time (docs/dev/backend-switch.md).
Not a behaviour change. Verified: Windows clippy -D warnings via
tools/fast-check PASS.
Windows call sites read the frame about 60 times and rely on the Win32
error (or unwrap_or_default). The shared window_rect is built on window(id),
which also asks title, class, exe and path and gives None for every failure.
Add the provided method Backend::frame(id) -> Result<Rect>: WindowGone for
an unknown window, Platform for a failed read. The default goes through
window() (a table lookup on KDE through Shared<B> and on the fake, so the
cached/requested-rect semantics of seam.md section 2 row 2 are kept);
WindowsBackend overrides it with Window::window_rect (one DWM call) and
MacosBackend with MacosApi::window_rect (the two Accessibility reads, no
metadata). The contract tests check frame agrees with window().rect and is
WindowGone for an unknown id; FakeBackend gets a test. A provided method, so
no adapter had to change to compile.
Not a behaviour change (nothing calls it yet). Verified: tools/fast-check
(native crate tests pass, Windows clippy -D warnings, KDE check + lib tests,
macOS fake-CC type-check) PASS; macOS cannot be run here.
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.
window_is_eligible (window.rs) took regex, ignore, manage, floating, then
layered, no-titlebar and slow; apply_globals (static_config.rs) took
ignore, regex, manage and the rest in yet another order: a rule check and
a config load could wait for each other for ever (the KDE tree hit this,
see ef1d3ef0 there).
One order is now documented at the statics in lib.rs: floating, session
floating, transparency, ignore, manage, layered, tray, object-name-change
(two), slow, no-titlebar, workspace rules, regex (a leaf: every rule check
takes its list and then the regexes). window_is_eligible takes the lists it
reads up front in that order and, once it has matched them all, drops every
guard BEFORE the slow-application sleep (before this, the sleep ran with
the regex, ignore, manage, floating, layered and no-titlebar guards held, so
a config load or rule command waited out the compensation time); apply_globals
is reordered. Every other site that nests two of these (state.rs,
process_command.rs session float rules, process_event.rs,
window_manager_event.rs, transparency_manager.rs, window_manager.rs,
workspace.rs) already followed the order.
BEHAVIOUR: lock acquisition order and hold time only; no rule semantics
change. Gate needed: Windows e2e commands and config_reload. Verified: not
yet re-run after the guard-drop change.
Regenerated komorebi-for-kde/nix/komorebi-options.nix from schema.json with schemars-nixgen (50ce286: sorted output, hash first line) and nix fmt. The checked-in file was stale after steps 2 and 3 changed description lines in the schema. Verified: nix build of kfde-schema-fresh and kfde-nix-options-validation from the root flake both succeed.
Regenerated komorebi-options.nix and komorebi-bar-options.nix from schema.json and schema.bar.json with schemars-nixgen (50ce286: sorted output, hash first line), then nix fmt from the root flake's formatter because the macOS flake has none on Linux. The generator was not run from the macOS tree's own just recipe. Verified: not built or evaluated on macOS; the macOS flake has no schema-fresh check, so the hash line is informational.
schemars-nixgen now writes the `# schema-sha256:` first line itself (schemars-nixgen 50ce286), so the justfile's printf and mv step would add a second one. Removes them and updates the comment. Verified: 'just nixgen' itself was not run (the recipe also builds a check); the same steps by hand gave a first line equal to `nix hash file --type sha256 --base16 schema.json`.
The doc of Backend::focus said Windows and macOS do focus and then center_cursor_in; writing the adapters showed that Window::focus on both takes mouse_follows_focus and centres the pointer itself (Windows also defers the focus while the window slides in). Doc comment only.
Verified: see the gates below; native cargo test -p komorebi-backend passes (doctests unchanged).
Appends section 9 to docs/dev/seam.md: for each method of the shared Backend, what WindowsBackend and MacosBackend do and where that differs from what the daemon calls today (windows() and macOS's registry cannot be written faithfully; set_rect on Windows drops the top flag and keeps animation and guards; hide/restore results are ignored on Windows; macOS hide needs a corner and a display; raise on macOS also focuses; macOS monitors() has to be a main-thread-refreshed cache; set_opacity on Windows is the plain write). Concludes that the trait did not have to change and records three proposals (rect as Option, hide's hidden inputs, windows() as start-up operation).
Verified: docs only, not built. Every claim is by reading the code while writing the adapters; what could not be settled by reading is marked 'not verified' in the text.
komorebi::macos_backend::MacosBackend implements komorebi_backend::Backend over the existing MacosApi, Window and AdhocWindow functions. It is NOT used by the daemon (no call site changed; that is step 11). No capability is supported (workspaces, maximize, opacity and focus-follows-mouse answer Unsupported).
Because nothing on macOS acts from a bare id, the adapter owns the id registry of seam.md consequence (1): the daemon would register(Window) and forget(id), every method looks the Window up by id and an unknown id is WindowGone. monitors() reads a cache that refresh_monitors(MainThreadMarker) fills on the main thread (the TARGET rule: no Backend method waits for main; the live NSScreen query panics off main). begin_batch/end_batch hold a stack of SkyLight BatchedUpdates guards. The parts that cannot be written faithfully (windows() is the registry, hide needs a corner and a display the trait has no place for, raise also focuses, no minimized/alive query that does not round-trip to the app, ...) are commented where they are and listed in seam.md section 9 (next revision).
komorebi-for-mac gains the komorebi-backend path dependency (workspace dependency, komorebi/Cargo.toml, Cargo.lock).
Verified: macOS fake-CC cargo check --locked --target aarch64-apple-darwin --workspace --all-targets: finished, 0 errors, no warning in macos_backend.rs. Not run: unit tests (macOS code cannot run here).
komorebi::windows_backend::WindowsBackend implements komorebi_backend::Backend over the existing static WindowsApi and Window methods. It is NOT used by the daemon (no call site changed; that is step 8). A window is WindowId::from_hwnd(hwnd) (every bit kept), a monitor MonitorId::from_hmonitor; maximize, opacity and focus-follows-mouse are supported, the five workspace methods answer Unsupported, batches are no-ops.
Methods that cannot be written without a difference in semantics are commented where they are and will be listed in docs/dev/seam.md section 9 (next revision): set_rect (the top flag is dropped; Window::set_position keeps its animation, slide-in, live-resize guard and same-frame skip), hide/restore/minimize/unminimize/maximize (ShowWindow results are ignored, so only an IsWindow pre-check can say WindowGone; hide and restore also drive the border and HIDDEN_HWNDS), windows() (alt-tab list, not the core's filtered candidates), set_opacity (plain write, not the animated, globally-configured Window::transparent), monitor_from_point (nearest monitor, never None).
Verified: nix develop cargo clippy --workspace --locked --all-targets -- -D warnings finished with no warnings or errors. Not run: unit tests (Windows code cannot run here).
komorebi::backend::shared::Shared<B> wraps any KDE Backend (the KWin one, the fake, a dyn Backend) and implements komorebi_backend::Backend over it, so KDE is the first implementation of the shared trait without any change to its own trait or call sites. Ids are WindowId::from_u32 (an id wider than u32 is a window KDE never had); a failed window command becomes Error::WindowGone when the window is no longer alive and Error::Platform(report) otherwise; every optional field is Some; every Capability is supported; batches are no-ops (KDE batches by construction).
Tests (5, in backend/shared.rs): the KDE fake, through Shared, passes the shared contract (check_all); the error mapping; wide ids; every capability supported; fields coming through.
Verified: komorebi-for-kde cargo test --workspace --no-fail-fast: 881 passed, 0 failed over 80 binaries (876 baseline + these 5). clippy -D warnings on komorebi-for-kde reports 3 ptr_arg errors in static_config.rs that predate this work; none in backend/.
komorebi::backend::fake::FakeBackend (and Command) keep their paths, signatures (u32 ids, eyre errors, the 18-variant Command) and behaviour, but the desktop is now komorebi_backend::fake::FakeBackend. The KDE type wraps it and translates ids and errors ('no such window: <id>' text is unchanged); the commands and state that only KDE has (apply_look, set_border_colours, set_wallpaper, drag_end and their getters) stay in the wrapper, and their commands are logged in the shared fake's log (Command::Ext) so their order among the others is kept. KDE's own trait Backend is untouched: that is the least invasive route, no call site and no test body changes (the 26 unit tests of fake.rs stay in the file byte for byte and now test the wrapper).
Cargo: komorebi-for-kde gains the komorebi-backend path dependency (workspace dependency plus komorebi/Cargo.toml; Cargo.lock updated).
Verified: in komorebi-for-kde, cargo test --workspace --no-fail-fast: 876 passed, 0 failed over 80 binaries (identical to the baseline; counts unchanged because the fake.rs tests were kept and the crate's tests are additional). The shared crate's own tests are counted separately.
komorebi_backend::contract: a Harness trait (how a test puts a live window on the desktop of the backend under test) and 14 checks, run by check_all::<H>(): windows listed by id; window agrees with windows/is_window/window_rect; an unknown window is not a window; every window command on an unknown or on a destroyed window fails with WindowGone naming that window; a destroyed window is neither alive nor listed; set_rect on a live window succeeds and the frame stays readable (a request: the value read is not checked); hide/restore tolerate repeats; focus names a known window; capabilities and Unsupported agree (supported means never Unsupported, unsupported means always Unsupported, with a live or unknown window); monitors are sane and found by point; Batch scopes nest around writes; the backend works from another thread; it is usable as a trait object.
Only what the Backend documentation promises is checked, because a write is a request and platforms act at different speeds. The fake passes under three configurations (plain, with a frame offset, with no capability at all, as macOS would be) and a deliberately broken backend (set_rect answers Ok for a gone window) is shown to fail exactly the two checks that cover it.
Verified: native cargo test -p komorebi-backend: 29 unit tests passed, 6 doctests passed, 1 compile_fail doctest passed, 0 failed; clippy --all-targets -D warnings clean.
The in-memory desktop of komorebi-for-kde (backend/fake.rs) moved into the shared crate, rewritten against WindowId/MonitorId/Result and the generic Backend only (look, border colours, wallpaper and drag frames stay out: they are KDE's).
Same behaviour as the KDE fake (permissive mode, minimum sizes, user_* helpers, maximize, fullscreen, workspaces, the ordered Command log with 15 of KDE's 18 variants; close() leaves the foreground window alone, as KDE's did), plus:
- failure injection: fail_next(Op, Error) and fail_next_for(Op, WindowId, Error), oldest first, one per call; the failed call is still logged as a command and changes nothing else (none existed on KDE);
- frame offsets: set_frame_offset / set_window_frame_offset make window_rect differ from the request by a constant, as the Windows shadow border does;
- capabilities: all four on by default, set_supported switches one off and its operations return Unsupported without being logged;
- batches: begin/end are counted (open_batches) and logged as BatchBegin/BatchEnd;
- FakeBackend<X>: a platform extension logs its own commands in order with record_ext (Command::Ext(X)); the shared fake is FakeBackend<NoExt> (new/permissive/with_one_monitor), an extension uses empty/permissive_ext/one_monitor because default type parameters are not inferred.
Verified: native cargo test -p komorebi-backend: 24 unit tests and 6 doctests passed, 0 failed (the KDE fake tests were ported and 6 failure/offset/capability/batch/extension tests added); clippy --all-targets -D warnings clean; cargo fmt applied.
New crate crates/komorebi-backend (edition 2024, root workspace member, depends only on komorebi-layouts for Rect).
- WindowId and MonitorId: opaque u64 newtypes. KDE and macOS ids convert with from_u32/to_u32; a Windows HWND/HMONITOR goes through from_hwnd/to_hwnd, which keep the bits of the isize unchanged (isize as usize as u64), so no handle is lost whether or not it fits in 32 bits (the e2e samples stay below 2^32, which is an observation, not a guarantee).
- WindowInfo and MonitorInfo: plain data; only id, pid, rect, minimized and alive are required, the rest (title, class, exe, path, fullscreen, maximized, normal; name and serial id of a monitor) are Option (seam.md consequence 6).
- Error: WindowGone(id) (finding 9: macOS uses a failed write as its signal that a window died), Unsupported(Capability) and Platform(cause).
- Backend: only the operations of seam.md section 2.1 that at least two platforms have (5 queries, 9 commands), a Capability query for workspaces, maximize, opacity and focus-follows-mouse (their methods default to Unsupported), begin_batch/end_batch with a no-op default plus the Batch guard (finding 8), the documented set_rect contract (a request; reads after a write return what the platform defines, consequence 2 as corrected) and the thread contract (any non-main thread, no waiting for the platform's main thread: consequences 3 and 4, written as TARGET rules). Every doc comment says which platforms implement the method.
Verified: native cargo test -p komorebi-backend (2 unit tests, 3 doctests, 0 failed) and cargo clippy -p komorebi-backend --all-targets -- -D warnings clean. The Windows/KDE/macOS gates are not affected yet (new crate, nothing depends on it).
bar.rs of the macOS bar still carries the Windows code it was copied from as comments: the PowerShell session (start/stop/exec), the InputConfig scroll state and its initialisation, the mouse configuration in apply_config, the hwnd field and its use, the CJK font fallbacks and the whole mouse handler of update. Those blocks (and the comments that only introduce them) are deleted; every live comment stays. The shared bar.rs of the later steps would otherwise inherit them.
Removed: 258 lines (the 269 of the digest included live comments that were kept).
Verified: macOS fake-CC cargo check --locked --workspace --all-targets finished, 0 errors (6 bar warnings, unchanged); rustfmt --check clean on bar.rs; harness regeneration byte-identical for both. Not verified: rendering.
komorebi-for-mac/komorebi-bar/src/widgets/keyboard.rs (177 lines, still written against the windows crate) and media.rs (122 lines) are not declared as modules (their mod lines in widgets/mod.rs are comments), so they are not part of the build; the widget variants that would use them are commented out in widget.rs. The files and the two commented-out mod lines are removed. The macOS bar has no keyboard or media widget; the config types of both live in the Windows bar and move to komorebi-bar-core with the platform seam. No behaviour change, no schema change.
Verified: macOS fake-CC cargo check --locked --workspace --all-targets finished, 0 errors (6 bar warnings, unchanged); harness regeneration byte-identical for both. Not verified: rendering.
Pure move of the three widget files that are byte-identical in the two bars since the previous revision. Each bar's widgets/mod.rs re-exports them (pub use komorebi_bar_core::widgets::memory / date / update). The core takes chrono, chrono-tz, reqwest (blocking) and serde_json (now a normal dependency, it was only a dev-dependency).
Removed: 541 lines from each bar (138 + 245 + 158), 541 added once.
Verified: Windows cargo clippy --workspace --locked --all-targets -D warnings clean; macOS fake-CC cargo check --locked --workspace --all-targets finished, 0 errors; native cargo test -p komorebi-bar-core 3 unit + 2 oracle passed; harness regeneration byte-identical for both (macOS 3,774 lines, Windows 9,091 lines). Not verified: rendering.
The three widgets that differ between the bars only by a platform fact now read it from the hook, in both trees identically: memory opens the task manager through open_system_tool(TaskManager) (was cmd.exe /C taskmgr.exe on Windows, open -a 'Activity Monitor' on macOS: the same commands, now in each platform.rs); date takes its calendar glyph from calendar_icon() (CALENDAR_DOTS on Windows, CALENDAR on macOS); update polls latest_release_api_url() (the komorebi and komorebi-for-mac release APIs) and opens the release page through open_system_tool(Url(..)) (explorer.exe on Windows; on macOS the same explorer.exe it spawns today, broken there, unchanged). After this the memory.rs, date.rs and update.rs of the two bars are byte-identical.
Verified: Windows cargo clippy --workspace --locked --all-targets -D warnings clean; macOS fake-CC cargo check --locked --workspace --all-targets finished, 0 errors; memory.rs, date.rs and update.rs byte-identical across the trees (diff). Note kept as it was: update.rs has a second GitHub API URL (the periodic refresh thread, line 85) that is the komorebi repo in both bars, also on macOS; only the first check goes through the hook. Not verified: clicks and the update check (no screen, no daemon).
The click on the cpu widget (task manager) and on the battery widget (power settings) now calls platform().open_system_tool(...) instead of spawning cmd.exe in shared code. The Windows hook spawns the same commands as before; the macOS hook still spawns the same (broken there) cmd.exe commands, so neither platform's behaviour changes. Fixing macOS is now a change to one function of komorebi-for-mac/komorebi-bar/src/platform.rs.
Verified: Windows cargo clippy --workspace --locked --all-targets -D warnings clean; macOS fake-CC cargo check --locked --workspace --all-targets finished, 0 errors; native cargo test -p komorebi-bar-core 3 unit + 2 oracle passed; harness regeneration byte-identical for both. Not verified: that a click still opens the tool (no screen).
komorebi_bar_core::platform holds what the widgets need from the operating system and differs between the bars: BarPlatform { open_system_tool, latest_release_api_url, calendar_icon }, the SystemTool enum (task manager, power settings, network settings, a URL) and install()/platform(), a once-set global the shell fills first thing in main() (a widget calls platform() when it is clicked or built, never before main). Each bar gets an os.rs with its implementation (main.rs re-exports the core module as crate::platform, so shared files can say crate::platform::platform()): Windows spawns exactly the commands the widgets spawn today (cmd.exe /C taskmgr.exe, cmd.exe /C start ms-settings:batterysaver, cmd.exe /C ncpa, explorer.exe <url>); macOS maps TaskManager to open -a 'Activity Monitor' and network settings to open x-apple.systempreferences:... as memory.rs and network.rs do today, and keeps the commands the shared files spawn on macOS today for the rest (cmd.exe taskmgr.exe for cpu, cmd.exe start ms-settings:batterysaver for battery, explorer.exe for a URL), which are broken there: a one-line fix per tool in os.rs, not part of this change.
Nothing calls the hooks yet: the next revisions switch the widgets over, one concern each.
Verified: Windows cargo clippy --workspace --locked --all-targets -D warnings clean; macOS fake-CC cargo check --locked --workspace --all-targets finished, 0 errors (6 bar warnings, unchanged); native cargo test -p komorebi-bar-core 3 unit + 2 oracle passed; rustfmt --check clean on the new files and both main.rs. No widget calls the hooks yet, so no behaviour changes.