Commit Graph
2548 Commits
Author SHA1 Message Date
LGUG2Z b65a32446e chore(repo): combine the kfw and kfm stacks for the e2e gate
Candidate for the Windows e2e gate: the Windows Backend switches and lock order (wip-u-kfw) with the macOS registry and Window methods (wip-u-kfm). Merge of two independent stacks that both touch crates/komorebi-backend; conflicts, if any, are resolved in this revision.
2026-10-31 10:55:01 -07:00
LGUG2Z 292a9ed567 docs(windows): record which call sites go through backend()
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.
2026-10-31 10:33:38 -07:00
LGUG2Z 5bffe0e93e refactor(windows): maximize and unmaximize go through backend()
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.
2026-10-31 10:32:25 -07:00
LGUG2Z a43d39635b refactor(windows): window_manager.rs reads frames through backend().frame()
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.
2026-10-31 10:31:13 -07:00
LGUG2Z 63904b736d refactor(windows): border_manager/border.rs reads frames through backend().frame()
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.
2026-10-31 10:31:13 -07:00
LGUG2Z d395b0e595 refactor(windows): process_event.rs reads frames through backend().frame()
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.
2026-10-31 10:31:13 -07:00
LGUG2Z 370dab364a refactor(windows): animation/ghost.rs reads frames through backend().frame()
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.
2026-10-31 10:31:13 -07:00
LGUG2Z c700502f15 refactor(windows): border_manager/mod.rs reads frames through backend().frame()
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.
2026-10-31 10:30:21 -07:00
LGUG2Z 74652fb451 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.
2026-10-31 10:30:10 -07:00
LGUG2Z 387d780aa7 refactor(windows): animation/ghost_dispatcher.rs reads frames through backend().frame()
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.
2026-10-31 10:29:44 -07:00
LGUG2Z 6a4db7dc5e refactor(windows): scrolling.rs reads frames through backend().frame()
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.
2026-10-31 10:29:14 -07:00
LGUG2Z 14b6112453 refactor(windows): pan.rs reads frames through backend().frame()
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.
2026-10-31 10:29:14 -07:00
LGUG2Z 07d6154483 refactor(windows): live_resize.rs reads frames through backend().frame()
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.
2026-10-31 10:28:50 -07:00
LGUG2Z 17ecb8787c refactor(windows): animation/snapshot.rs reads frames through backend().frame()
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.
2026-10-31 10:28:28 -07:00
LGUG2Z 7ba4327fa0 refactor(windows): stackbar_manager/stackbar.rs reads frames through backend().frame()
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.
2026-10-31 10:28:06 -07:00
LGUG2Z b580b29f44 refactor(windows): stackbar_manager/mod.rs reads frames through backend().frame()
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.
2026-10-31 10:24:08 -07:00
LGUG2Z 8a304c62dc wip 2026-10-31 10:22:43 -07:00
LGUG2Z f5a299aa9e refactor(windows): minimize, close and raise go through backend()
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.
2026-10-31 10:22:41 -07:00
LGUG2Z fad90dbd3e refactor(windows): plain hide and restore go through backend()
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.
2026-10-31 10:22:41 -07:00
LGUG2Z 3a86e8fb6a refactor(windows): frame writes with top = false go through backend()
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.
2026-10-31 10:22:40 -07:00
LGUG2Z 078bdc1666 refactor(windows): focus goes through backend()
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.
2026-10-31 10:22:40 -07:00
LGUG2Z 07f931d6cb feat(windows): backend() accessor for the daemon
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.
2026-10-31 10:22:39 -07:00
LGUG2Z 0a2562b9cf feat(backend): frame(id) is a cheap live frame query with the reason for a failure
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.
2026-10-31 10:22:38 -07:00
LGUG2Z 69073153d9 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.
2026-10-31 10:14:06 -07:00
LGUG2Z 8f37b9aea6 fix(windows): take the rule-list locks in one documented order
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.
2026-10-31 10:14:06 -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