Commit Graph
2533 Commits
Author SHA1 Message Date
LGUG2Z afd0f82f91 style(mac-bar): spell the stroke widths 1.0_f32 (float_literal_f32_fallback)
Six literals in the macOS bar (applications.rs, komorebi.rs x3, komorebi_layout.rs,
time.rs) passed 1.0 to egui's Stroke::new, which rustc 1.99 reports as an f32
fallback (a future hard error). The Windows bar and komorebi-bar-core
already say 1.0_f32 for the same calls, so this makes the macOS bar text
match them; the value is the same f32. No behaviour change.

Verified: fake-CC cargo clippy --locked --target aarch64-apple-darwin
--workspace --all-targets -D warnings: clean (whole workspace). The Windows
bar and komorebi-bar-core are untouched. Verified on the Mini: not yet.
2026-11-05 10:30:05 -08:00
LGUG2Z b9125ddb65 style(mac): sample the capture spike's pixels with chunks(4) and a length filter (clippy)
examples/capture_spike.rs iterated bytes.chunks_exact(4), which clippy flags
as chunks_exact_with_const_size on 1.93 and as chunks_exact_to_as_chunks on
1.99 (the allow name differs between the two, so an allow cannot serve
both). chunks(4).filter(len == 4) visits the same full pixels in the same
order and still drops a trailing partial one; the spike is an example
binary, not the daemon. No behaviour change.

Verified: fake-CC cargo clippy --locked --target aarch64-apple-darwin
--workspace --all-targets -D warnings: clean (whole workspace). Verified on
the Mini: not yet.
2026-11-05 10:30:05 -08:00
LGUG2Z a35573d8eb fix(kde): StaticConfigExt takes &Path instead of &PathBuf (clippy::ptr_arg)
The KDE twin of the macOS fix: the trait declarations of preload, postload
and reload (static_config.rs:726, :732, :735; the impls follow) took
&PathBuf, introduced by the same step 3 conversion to the extension trait.
read takes &Path since the config-crate revision; the one clone of the path
is path.to_path_buf(). No behaviour change.

Verified: native cargo clippy --locked -p komorebi --all-targets -D warnings
in komorebi-for-kde: clean (the 3 ptr_arg errors that predated the backend
work are gone); cargo test --locked -p komorebi --lib: 294 passed, 0 failed.
2026-10-31 12:39:24 -07:00
LGUG2Z 5055e8a639 style(mac): allow clippy::collapsible_match at three nested ifs, with a reason
monitor.rs (two ifs that choose where a moved container goes, inside a match
on the layout) and static_config.rs handle_asc_file (a 40-line block under
the extension check). The lint wants the if folded into the outer match
arm as a guard; doing that restructures the arms (the else branches become
extra arms) without changing what they do, which is more edit than a lint
fix should be and cannot be run here, so each site gets an allow with a
comment instead. No behaviour change. Pre-existing on the original macOS
tip 9a58e511.

Verified: fake-CC cargo clippy --locked --target aarch64-apple-darwin -p komorebi --all-targets -D warnings: the daemon lib and its tests are clean with the six hygiene and ptr_arg revisions applied (the whole-workspace run still reports newer-clippy lints that the Mini's 1.93 does not have: the bar's f32 literal fallback and examples/capture_spike.rs chunks_exact). Verified on the Mini: not yet.
2026-10-31 12:38:08 -07:00
LGUG2Z f9f47f3fb4 style(mac): sort the layout rules with sort_by_key (clippy::unnecessary_sort_by)
window_manager.rs sorted (usize, Layout) pairs by their first field with a comparator closure; sort_by_key on the same field is the same stable sort.

No behaviour change. Pre-existing on the original macOS tip 9a58e511 (reported by cargo clippy --all-targets -D warnings on the Mini, stable 1.93).

Verified: fake-CC cargo clippy --locked --target aarch64-apple-darwin -p komorebi --all-targets -D warnings no longer reports this lint (the last hygiene revision records the whole run). Verified on the Mini: not yet.
2026-10-31 12:37:18 -07:00
LGUG2Z d9837200c3 style(mac): fill resize_dimensions with None in one call (clippy::manual_slice_fill)
window_manager.rs reset every entry of workspace.resize_dimensions in a for loop; fill(None) does the same.

No behaviour change. Pre-existing on the original macOS tip 9a58e511 (reported by cargo clippy --all-targets -D warnings on the Mini, stable 1.93).

Verified: fake-CC cargo clippy --locked --target aarch64-apple-darwin -p komorebi --all-targets -D warnings no longer reports this lint (the last hygiene revision records the whole run). Verified on the Mini: not yet.
2026-10-31 12:37:18 -07:00
LGUG2Z 756a03cc77 style(mac): use Option::filter for the non-empty window name (clippy::manual_filter)
window.rs WindowInfo::from(&CFDictionary) spelled filter by hand with and_then; an empty name is still None.

No behaviour change. Pre-existing on the original macOS tip 9a58e511 (reported by cargo clippy --all-targets -D warnings on the Mini, stable 1.93).

Verified: fake-CC cargo clippy --locked --target aarch64-apple-darwin -p komorebi --all-targets -D warnings no longer reports this lint (see the last hygiene revision for the whole run). Verified on the Mini: not yet.
2026-10-31 12:37:12 -07:00
LGUG2Z 552ab43701 style(mac): take the workspaces with mem::take instead of drain(..).collect() (clippy::drain_collect)
monitor.rs remove_workspaces moved every workspace into a new VecDeque through drain; mem::take moves the whole deque and leaves an empty one, which is the same result without the second allocation.

No behaviour change. Pre-existing on the original macOS tip 9a58e511 (reported by cargo clippy --all-targets -D warnings on the Mini, stable 1.93).

Verified: fake-CC cargo clippy --locked --target aarch64-apple-darwin -p komorebi --all-targets -D warnings no longer reports this lint (see the last hygiene revision for the whole run). Verified on the Mini: not yet.
2026-10-31 12:37:12 -07:00
LGUG2Z 1c64168759 fix(mac): StaticConfigExt takes &Path instead of &PathBuf (clippy::ptr_arg)
Fixes the 3 new lints at static_config.rs:719, :726 and :729 (the trait
declarations of preload, postload and reload; the impls follow). They were
introduced by kvtvnouo, 'refactor(mac): use StaticConfig and its family of
komorebi-config', which turned the inherent methods into the extension
trait; the original tip 9a58e511 did not have them. read gets a &Path
through the previous revision, and the one clone of the path (the
ReloadStaticConfiguration message) is path.to_path_buf(). No behaviour
change.

Verified: macOS fake-CC type-check (tools/fast-check) PASS, and fake-CC
cargo clippy -p komorebi --all-targets -D warnings no longer reports the
three. Verified on the Mini: not yet (cargo clippy --all-targets -D warnings).
2026-10-31 12:37:12 -07:00
LGUG2Z 1e10f45bb9 refactor(config): StaticConfig::read takes &Path, not &PathBuf
clippy::ptr_arg: the function only opens the file, so any path will do, and
every caller that passes a &PathBuf still compiles through deref. Needed so
the macOS StaticConfigExt methods can take &Path (next revision).

Verified: fast-check native, Windows clippy -D warnings, KDE check and lib
tests, macOS fake-CC type-check PASS. Verified on the Mini: not yet.
2026-10-31 12:36:14 -07:00
LGUG2Z ec0d3923e5 docs(macos): add the id registry revisions to the hand-check list
Adds the three BEHAVIOUR-relevant registry revisions (registration and
forgetting, native-tab sync) with what to look for on a Mac, the mechanical
ones to section B, and a status entry in the bug list saying what of step
11(ii) is done and what is deliberately not (animator lanes, borders,
reaper/live-resize timeouts, the model holding bare ids).

Verified: documentation only.
2026-10-31 10:12:30 -07:00
LGUG2Z 01b3bd5cea refactor(mac): the live-resize step reads the dragged window's frame through Window
Step 11(ii), fifth part. window_manager.rs cloned the dragged window's
element out of the workspace only to call MacosApi::window_rect on it; it
now asks the Window found in the container for window_rect (the same call on
the same element). One raw AX site fewer outside Window. The error is the
same one the old call returned, still propagated with ?. Not behaviour.

Verified: macOS fake-CC type-check (tools/fast-check) PASS. Not verified:
cannot run on Linux.
2026-10-31 10:12:11 -07:00
LGUG2Z ba22e8dc5a refactor(mac): turn a system-handed element into a window id in one place
Step 11(ii), fourth part. The seven sites that derive a CGWindowID from an
element that the system handed over (event tap, observer callbacks, the
focused window of an app, the tab check) call ax_registry::identify instead
of AccessibilityApi::window_id: input_event_listener.rs, process_command.rs,
process_event.rs (5), window_manager.rs. It is the same call; the point is
that an element becomes an id only here, which is the key the registry is
filled under. Not behaviour: nothing changes at runtime.

Verified: macOS fake-CC type-check (tools/fast-check) PASS. Not verified:
cannot run on Linux.
2026-10-31 10:11:28 -07:00
LGUG2Z e0687167b4 refactor(mac): keep ax_registry in step when a native tab changes a window's id
Step 11(ii), third part. BEHAVIOUR (bookkeeping only). The two places in
process_event.rs that swap a window's id and element in place when a native
tabbed application shows another tab now call ax_registry::sync(old_id,
window): the old id is forgotten and the window registered as it now is, so
the table never names an element that the model has replaced. No AX call is
added.

Verified: macOS fake-CC type-check (tools/fast-check) PASS. Not verified:
cannot run on Linux. Gate needed: Mac hand check with a tabbed app
(Terminal or Finder tabs; see docs/dev/macos-handcheck.md): switch tabs,
close the first tab, focus the window by command; behaviour must match the
baseline.
2026-10-31 10:10:53 -07:00
LGUG2Z f0b1a448d4 refactor(mac): register every Window in ax_registry and forget the dead
Step 11(ii), second part. BEHAVIOUR (memory and bookkeeping only; no AX call
is added anywhere, and no existing call reads the table yet except the
still-unused MacosBackend).

Window::new registers the window under its id. Entries end where the daemon
learns of a death: Window::drop when the window is no longer alive (next to
the InvalidWindow notification it already sends), reap_window in the reaper,
and WindowManagerEvent::Destroy for NSWorkspaceDidTerminateApplication
(forget_pid, next to enhanced_ui::forget: a new process may reuse the pid).
A live window that is never managed stays registered until it dies or its
application quits; the table holds retained references that the Window clones
held anyway. The native tab case (id and element changed in place) follows in
its own revision.

Verified: macOS fake-CC type-check (tools/fast-check) PASS. Not verified:
cannot run on Linux. Gate needed: the Mac hand check, see
docs/dev/macos-handcheck.md (open and close many windows and quit apps; the
daemon's memory must not grow; nothing else should look different).
2026-10-31 10:10:38 -07:00
LGUG2Z 386c5a79c6 refactor(mac): ax_registry, the id -> {element, observer, application} table
Step 11(ii), first part. New module ax_registry.rs instantiates
komorebi_backend::Registry (rules tested natively in 4c9094d7) with AxEntry
{element, observer, application with its pid}; lifetime and thread rules are
written at the top of the file: entries end on Window::drop of a dead window,
reaper reaping and application termination (wired in the next revisions);
nothing in it dispatches to main or takes the WM lock; removed entries are
dropped after the table's lock is released. Window gets entry() and
from_entry() to convert. MacosBackend drops its private HashMap<u32, Window>
and looks windows up here (register and forget delegate), so the compile-only
adapter now resolves an id the same way the daemon will.

BEHAVIOUR: none yet, nothing registers (the adapter is still unused by the
daemon). Verified: macOS fake-CC type-check (tools/fast-check) PASS. Not
verified: cannot run on Linux.
2026-10-31 10:10:15 -07:00
LGUG2Z 4c9094d776 feat(backend): Registry, a thread-safe table from WindowId to a platform handle
Step 11(ii), the pure part. macOS cannot act on a window from its id: it
needs the Accessibility element, the pid and the observer. Registry<H> is
that table, generic over the handle so that its rules run on any host.
Rules, written at the top of registry.rs and tested: thread-safe; a
lookup clones the handle and releases the lock before anything is done to
it; a removed or replaced handle is handed back to the caller instead of
being dropped under the lock (dropping a macOS handle can make an AX round
trip, which must never happen with a lock held: seam.md 3.3); a stale or
unknown id is Error::WindowGone, never a panic; an entry ends on remove,
remove_pid (application quit) or a failed call; re-inserting replaces.

Nothing uses it yet; no daemon changes.

Verified: native cargo test -p komorebi-backend: 38 unit (9 new) + 7 doc
(1 new) + 1 compile_fail passed, 0 failed. Not run: the Windows, KDE and macOS
checks (the new module is std-only and no other file changed).
2026-10-31 10:08:57 -07:00
LGUG2Z f157aa34e9 docs(macos): the hand-check list for a real Mac
Lists what must be checked on a Mac once the unified binaries exist: every
macOS revision that changes runtime behaviour (the rule-list lock order,
the shared command listener, pause filter, subscriber push, EventChannel,
SocketMessage, animation prefix, StaticConfig, komorebic launcher, bar-core
hooks and library bumps), the mechanical Step 6/11(i) revisions of this
stack, the walk-through the plan names (focus, move, stack, workspaces,
scrolling, pan, borders, animations, display change, sleep and wake), and
the bugs noticed: the main-queue/WM-lock deadlock of seam.md 3.3, cmd.exe
and explorer.exe in the macOS bar, the update widget's wrong repo, the raw
AX sites that remain outside Window.

Nothing in it was run: macOS cannot be built or tested on this host.
Verified: documentation only.
2026-10-31 10:03:24 -07:00
LGUG2Z 931b17d748 refactor(mac): name the Window frame query window_rect, as the Backend and the Windows Window do
Renames Window::frame (added two revisions back) to Window::window_rect and
its 28 callers: Backend::window_rect is the shared name, and the Windows Window
got the same one (wip-u-kfw mkwoqsvs). Same body; nothing changes at runtime.

Verified: macOS fake-CC type-check (tools/fast-check) PASS. Not verified:
cannot run or unit-test on Linux.
2026-10-31 10:02:36 -07:00
LGUG2Z d30a3eb686 refactor(mac): MacosBackend reaches a window only through Window methods
Step 11(i). The compile-only adapter still read the Accessibility element
for two things: the minimized flag (copy_attribute_value of kAXMinimized)
and close (AdhocWindow::close on the element). Window::minimized is added
(the same query, on self.element) and the adapter now calls it and
Window::close; with set_rect, focus, raise, hide, restore, minimize,
unminimize, alive and frame (earlier revisions) every operation of the
adapter is a Window method and the file imports no AccessibilityApi. The
adapter is still not used by the daemon, so nothing changes at runtime.
Steps 11(ii) (id registry) and (iii) are not started.

Verified: macOS fake-CC type-check (tools/fast-check) PASS. Not verified:
cannot run or unit-test on Linux.
2026-10-31 10:01:30 -07:00
LGUG2Z ecaa3e1516 refactor(mac): give Window a close operation
Adds Window::close (Backend::close): the same press of the close button
that AdhocWindow::close does on a bare element, applied to the Window's
element. Nothing calls it yet; MacosBackend switches to it in the next
step. No behaviour change: the daemon's own close command still goes through
AdhocWindow on the foreground element, because it has no Window there.

Verified: macOS fake-CC type-check (tools/fast-check) PASS. Not verified:
cannot run or unit-test on Linux.
2026-10-31 10:01:04 -07:00
LGUG2Z 803a141088 refactor(mac): set a window's AX messaging timeout through Window
Adds Window::set_messaging_timeout and uses it in settle.rs (the look at a
window after a drag, 3 raw AX sites) and in Window::note_arrival. Same call
on the same element; nothing changes at runtime. It is not one of the
shared Backend operations, but it bounds the frame query, so the raw AX
call leaves settle.rs with the frame read. The window manager's timeouts
list and the animator keep calling AccessibilityApi: they hold elements
(app elements, lane handles), not Windows.

Verified: macOS fake-CC type-check (tools/fast-check) PASS. Not verified:
cannot run or unit-test on Linux.
2026-10-31 10:00:34 -07:00
LGUG2Z 49a6dbdabb 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.
2026-10-31 10:00:03 -07:00
LGUG2Z 7c2e1bea8a refactor(mac): name the Window liveness check alive, as the shared Backend does
Renames Window::is_valid to Window::alive (window.rs, reaper.rs,
workspace.rs, macos_backend.rs). Same body (the element still answers a
copy-attribute-names query), so nothing changes at runtime. Application::is_valid
is a different type and keeps its name. This is the 'alive' operation of the
step 6 list.

Verified: macOS fake-CC type-check (tools/fast-check) PASS. Not verified:
cannot run or unit-test on Linux.
2026-10-31 09:59:49 -07:00
LGUG2Z 796c3832b7 refactor(mac): ask a Window for its frame instead of reading the AX element
Adds Window::frame(), the frame query (Backend::window_rect), and routes
the 28 sites that read a Window's frame through MacosApi::window_rect(&w.element)
(window.rs, window_manager.rs, workspace.rs, process_event.rs,
process_command.rs, settle.rs, macos_backend.rs) through it. frame() is the
same call on the same element, so nothing changes at runtime. Sites that hold
a bare element rather than a Window (tabs in process_event.rs, borders,
the animator, AdhocWindow) are left as they are.

Step 6 of the consolidation, macOS, one operation per revision.

Verified: macOS fake-CC type-check (tools/fast-check) PASS. Not verified:
cannot run or unit-test on Linux.
2026-10-31 09:59:17 -07:00
LGUG2Z 01b9cbed91 fix(mac): take the rule-list locks in one order, so a rule check and a config load cannot deadlock
BEHAVIOUR (lock order only). window.rs (should_manage rule check) took the
regex list, then ignore, then manage, then floating; static_config.rs
(apply_globals) took ignore, regex, manage, floating. Two threads, one
checking a window and one loading the config, could each hold what the
other waits for. Same defect as the KDE fix ef1d3ef0; the order is now the
KDE one minus the lists macOS lacks: floating, (session floating),
ignore, manage, (workspace rules), regex. Both sites acquire in that order
and the order is documented at the statics in lib.rs. The other holders
(process_event.rs floating -> regex, process_command.rs floating ->
session floating, window_manager.rs workspace rules -> regex) already
follow it; every other site takes a single rule list.

Verified: macOS fake-CC type-check (tools/fast-check) PASS. Not verified:
cannot run on Linux; a deadlock is not reproducible by reading anyway. Gate
needed: none runnable here; hand check on a Mac (docs/dev/macos-handcheck.md):
reload the config while windows open/close.
2026-10-31 09:54:18 -07:00
LGUG2Z 633e7453cd chore(nix): regenerate the KDE options file from the current schema
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.
2026-10-31 08:45:32 -07:00
LGUG2Z 9c3dcf8159 chore(nix): regenerate the macOS options files with the hash line
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.
2026-10-31 08:45:32 -07:00
LGUG2Z a415922a46 build(kde): let schemars-nixgen write the schema hash line in nixgen
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`.
2026-10-31 08:45:32 -07:00
LGUG2Z 83819b22b1 docs(backend): focus is one call on Windows and macOS too
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).
2026-10-31 01:37:54 -07:00
LGUG2Z 7260c9f772 docs(seam): findings from the 7c adapters (section 9)
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.
2026-10-31 01:37:54 -07:00
LGUG2Z bd3454e433 feat(macos): MacosBackend, a compile-only adapter for the shared Backend
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).
2026-10-31 01:37:54 -07:00
LGUG2Z 76d25c8843 feat(windows): WindowsBackend, a compile-only adapter for the shared Backend
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).
2026-10-31 01:37:54 -07:00
LGUG2Z 9bf77e32b9 feat(kde): KDE backends implement the shared Backend through Shared
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/.
2026-10-31 01:37:54 -07:00
LGUG2Z 1497e5d62a refactor(kde): the fake backend wraps komorebi-backend's FakeBackend
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.
2026-10-31 01:37:54 -07:00
LGUG2Z 998396dfc5 test(backend): contract tests that any Backend must pass
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.
2026-10-31 01:37:54 -07:00
LGUG2Z 6874a51769 feat(backend): FakeBackend with failure injection and frame offsets
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.
2026-10-31 01:37:54 -07:00
LGUG2Z f08237d402 feat(backend): the shared Backend trait, WindowId, plain-data infos and the error type
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).
2026-10-31 01:37:54 -07:00
LGUG2Z 1b8fdcdcc9 refactor(mac-bar): delete the commented-out Windows code in bar.rs
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.
2026-10-31 01:37:54 -07:00
LGUG2Z d0bb7465f6 refactor(mac-bar): delete keyboard.rs and media.rs, which nothing compiles
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.
2026-10-31 01:37:54 -07:00
LGUG2Z 6da27dda3c refactor(bar-core): move the memory, date and update widgets into komorebi-bar-core
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.
2026-10-31 01:37:54 -07:00
LGUG2Z 7cd85bd446 refactor(bar): memory, date and update use the platform hooks
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).
2026-10-31 01:37:54 -07:00
LGUG2Z b8de056b28 refactor(bar-core): the cpu and battery widgets open their tools through the platform hook
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).
2026-10-31 01:37:54 -07:00
LGUG2Z 086833af96 refactor(bar-core): add the BarPlatform hooks with the Windows and macOS implementations
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.
2026-10-31 01:37:54 -07:00
LGUG2Z 98f9e184a2 refactor(bar-core): move the battery and cpu widgets into komorebi-bar-core
Pure move of the two widget files that are byte-identical in the Windows and macOS bars. Each bar's widgets/mod.rs re-exports them (pub use komorebi_bar_core::widgets::battery / cpu), so crate::widgets::battery::... resolves as before; the files themselves are unchanged.

Dependencies: the core takes sysinfo from the root workspace (0.39) and starship-battery 0.11, the versions the Windows bar already used. The macOS bar therefore now gets these two widgets built against sysinfo 0.39 (its own workspace pins 0.38, still used by its other widgets until they move) and starship-battery 0.11 (was 0.10; its own dependency on the crate is removed). Both compile unchanged; behaviour of the libraries is not verified on macOS.

Not changed on purpose: the macOS bug that these two files spawn cmd.exe (taskmgr.exe, explorer.exe) on click is still there, identically; it is fixed behind the platform hook, not inside a move.

Removed: 325 lines from each bar (191 + 134), 325 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 (bar warnings 6, unchanged; macOS Cargo.lock: starship-battery 0.10.3 -> 0.11.1 with its dependencies (uom, plist, nix), sysinfo 0.39.6 added next to 0.38.4); native cargo test -p komorebi-bar-core 3 unit + 2 oracle passed; harness regeneration (S/bar2/regen.sh, which now fails when a harness does not build): macOS byte-identical (3,774 lines), Windows byte-identical (9,091 lines). Not verified: rendering, sysinfo and starship-battery behaviour on macOS.
2026-10-31 01:37:54 -07:00
LGUG2Z c05ef98d77 refactor(bar-core): the BarWidget trait moves into komorebi-bar-core
The three-line trait every widget implements is split off widgets/widget.rs (the WidgetConfig enum stays there until every widget it names has moved) and becomes komorebi_bar_core::widgets::widget::BarWidget; each bar's widget.rs re-exports it, so crate::widgets::widget::BarWidget resolves as before. The core's config module re-exports the leaf types (crate::config::LabelPrefix) so that the widgets can later move without a text edit.

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. No schema type changed. Not verified: rendering.
2026-10-31 01:37:54 -07:00
LGUG2Z d5ad916ff1 refactor(bar-core): move render.rs into komorebi-bar-core
Pure move of render.rs (RenderConfig, Grouping, GroupingConfig, GroupingStyle, RoundingConfig and the helpers), byte-identical in both bars since the three previous revisions, with the one path edit the move needs: Alignment is imported from komorebi_bar_core::alignment instead of crate::bar. Each bar's main.rs re-exports the module (pub use komorebi_bar_core::render), so crate::render::... resolves as before.

Removed: 382 lines from each bar, 382 added once.

Note: the one added line is #[allow(clippy::new_without_default)] on RenderConfig::new, which clippy now asks for because the type is public API of a library crate.

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: macOS byte-identical (3,774 lines), Windows byte-identical (9,091 lines). Not verified: rendering.
2026-10-31 01:37:54 -07:00
LGUG2Z 03d454de17 refactor(bar): the RenderExt impl for KomobarConfig moves from render.rs to config.rs
render.rs is about to move into komorebi-bar-core and must not know KomobarConfig. The only place it did was impl RenderExt for &KomobarConfig (the trait and RenderConfig stay in render.rs); that block, byte-identical in both bars, becomes the last item of config.rs with its imports. No behaviour change.

Verified: Windows cargo clippy --workspace --locked --all-targets -D warnings clean; macOS fake-CC cargo check --locked --workspace --all-targets finished, 0 errors; rustfmt --check clean on both config.rs and render.rs. Not verified: rendering.
2026-10-31 01:37:54 -07:00
LGUG2Z a3afb3a94b refactor(bar): GroupingConfig.transparency_alpha has one spelling in render.rs
The two render.rs differed in two places. The Windows bar documented transparency_alpha with '(default: 200)' in its text; the macOS bar documented it without and put the default into the schema (schemars extend default 200), so the macOS nix options file gets default = 200. The macOS spelling is taken for both, because a change to the macOS schema.bar.json would also change the generated nix/komorebi-bar-options.nix, which cannot be regenerated here. Windows: the description loses the '(default: 200)' text and the property gains "default": 200 (reviewed diff of schema.bar.json below, pin updated in tests/schema_oracle.rs); the one comment on RenderConfig that only Windows had ('/// Render configuration') is added to the macOS copy. The two render.rs are then byte-identical.

The schema diff is the two lines of the property: description 'Alpha value for the color transparency [[0-255]] (default: 200)' -> 'Alpha value for the color transparency [[0-255]]', and one added "default": 200. macOS schema.bar.json is untouched (its harness regeneration is 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; native cargo test -p komorebi-bar-core: 3 unit + 2 oracle passed, 0 failed; harness regeneration: macOS byte-identical (3,774 lines), Windows byte-identical to the updated schema.bar.json (9,091 lines, diff exactly the two lines above). Not verified: rendering.
2026-10-31 01:37:54 -07:00
LGUG2Z 70bff5d549 refactor(bar): render.rs takes Colour and Rgb from komorebi-themes
komorebi_client::Colour and ::Rgb are re-exports of komorebi_themes::colour::Colour and ::Rgb in both trees; naming the crate that defines them lets render.rs move into komorebi-bar-core, which must not depend on komorebi_client (D25). Both bars' render.rs change identically. No behaviour change.

Verified: Windows cargo clippy --workspace --locked --all-targets -D warnings clean; macOS fake-CC cargo check --locked --workspace --all-targets finished, 0 errors. Types are the same re-exports, so no schema change. Not verified: rendering.
2026-10-31 01:37:54 -07:00