# The platform seam: evidence Status: evidence document (step 7a of the consolidation). No `Backend` trait is proposed here as code, and none may be written before this document has been reviewed. Every statement about the code carries a citation; where I could not confirm something it says "not verified" and the item is collected in section 8. ## 1. Purpose and how to read it A shared `Backend` seam has to sit between code that is to be shared (windows, containers, workspaces, monitors, commands, event handling) and three platform layers that today do the same jobs in three different ways. A trait written from memory of one platform would bake that platform's assumptions into the other two. This document records what each platform actually does, so that the trait can be derived from facts. - **Facts** are the tables and the numbered findings, each with a `file:line` citation read on the tips below. Nothing in a table is a proposal. - **Proposals** are confined to section 7 (consequences). Each consequence is a statement about what the seam must satisfy, with the facts that support it, and is marked CONFIRMED, CORRECTED or TARGET (not true of any current code, but something the seam would have to make true). - "Not verified" means I read the code and could not settle the point by reading (usually: Apple or Microsoft runtime behaviour, or behaviour that needs a Mac). It does not mean "false". Tips read: integration line `wip-main` at `aa52fdc4d9e5` (`build(nix): relock the nested flakes after the step 1 and crates changes`). The three trees live in one checkout: | Tree | Prefix used below | Path | |---|---|---| | Windows (repo root) | `W/` | `komorebi/src/` | | KDE | `K/` | `komorebi-for-kde/komorebi/src/` | | macOS | `M/` | `komorebi-for-mac/komorebi/src/` | Shared crates are cited with their full path (`komorebi-layouts/src/rect.rs`). Only reading and `grep` were used; nothing was compiled or run, and no macOS or Windows runtime behaviour was observed. ## Corrections to earlier claims Things in the plan (`generic-percolating-matsumoto.md`, Step 7 and "Risks") or the progress log that this reading contradicts or refines. 1. **KDE `Backend` method count.** The trait declares **31** methods: 19 required (`K/backend/mod.rs:242-258`, `325-389`, `408-432`) and 12 provided (`:280`, `:311`, `:473`, `:504`, `:529`, `:553`, `:586`, `:597`, `:607`, `:612`, `:617`, `:622`). The plan's "28 (not 31)" matches only if the three derived helpers `is_window`, `window_rect`, `monitor_from_point` (`:612-628`, written in terms of `window` and `monitors`) are left out. Use "28 primitives plus 3 derived". 2. **macOS `monitors()` is not a cache** (already corrected by the kfm A0 report, confirmed). `MacosApi::latest_monitor_information` queries `NSScreen` live and does `MainThreadMarker::new().unwrap()` (`M/macos_api.rs:212-213`), so it panics off the main thread; every caller is already on main (section 3.3). "monitors() reads a cache refreshed by the display callback" is a TARGET (consequence 4). 3. **Consequence 2 is too strong as written.** "`set_rect` is never read back to confirm" is false of macOS: after a direct write the layout reads the frame back to learn whether the app refused the width (`M/window.rs:944-972`, `M/arrival.rs:1-12`), and the animator verifies each journey (`M/animation/animator.rs:902`). KDE returns an optimistic value: `set_rect` writes the requested rect into its own table at once (`K/kwin/state.rs:596-600`, called from `K/kwin/mod.rs:855`). The defensible contract is in section 7. 4. **The KDE `u32` id is not "the compositor's".** The doc comments say so (`K/backend/mod.rs:65`, `K/window.rs:78-81`), but the id is a counter that the daemon assigns to each KWin UUID string (`K/kwin/state.rs:153-154`, `603-611`). KDE already has a registry (uuid <-> id) behind its backend, and `KWinBackend::command` resolves every command through it (`K/kwin/mod.rs:797-806`). 5. **The macOS deadlock has more entry points than the plan lists.** The plan names `destroy_all_borders` from the event thread (`M/process_event.rs:128, 139`). A blocking main-queue dispatch under the window-manager lock also happens from the event thread at `M/process_event.rs:791` (`activate_finder`, `M/macos_api.rs:492`), and from command threads (`M/process_command.rs:294, 303, 1776, 1802, 1806`) and workspace switching (`M/window_manager.rs:1385`, `2286`). Section 3.3. 6. **Windows HWND width**: the code never narrows an HWND, so it assumes nothing about 32-bit significance (section 4). The Microsoft-documented fact that handles are 32-bit significant is not verified here. 7. **Counts** (re-measured; method in section 2.3). KDE trait: 31 (not 28, see 1). Windows `WindowsApi`: 71 distinct functions used outside `windows_api.rs` (matches), 280 call sites in `W/` plus 3 in `komorebi-bar/src/bar.rs` = 283 (earlier survey 279). The generic / Windows-only split depends entirely on the rule used; with the rule stated in 2.3 it is 41 / 30 functions and 219 / 61 sites (earlier survey 42 / 29 and 209 / 70). macOS: 14 `MacosApi` functions, 5 of 8 `CoreGraphicsApi` functions, 13 `AccessibilityApi` functions are used outside their API files; the earlier "52 raw AX sites, 33 in window.rs" does not reproduce for the total: **67** `AccessibilityApi::` sites in 12 files, 33 of them in `M/window.rs` (that part agrees). 8. **The plan's list of macOS main-thread-only work is incomplete in one respect.** The AX observer and event-tap callbacks run on main and do synchronous AX IPC to other applications there (`M/window.rs:288-350`, `M/input_event_listener.rs:96-100`): "main thread" is not just "cheap UI work". 9. **macOS has no focus-follows-mouse implementation**, only config/state fields (`grep` finds `FocusFollowsMouse` in `M/static_config.rs`, `M/state.rs`, `M/core/mod.rs` and nowhere else); KDE and Windows both have one. The plan lists focus-follows-mouse among platform subsystems; for macOS it is absent, not platform-specific. ## 2. The operation table Conventions. "Rect" is the shared `komorebi_layouts::Rect`: `left`, `top` are the origin and **`right`, `bottom` hold the width and height**, not the far edge (`komorebi-layouts/src/rect.rs:19-28`; the conversions `From` at `:32-41`, `From` at `:76-86`). "Queued" means the call returns before the platform has acted; "sync" means the calling thread waits for the platform to answer. Row numbers are for reference in later sections. ### 2.1 Operations present on at least two platforms | # | Operation | KDE `Backend` method | Windows | macOS | Semantic differences | |---|---|---|---|---|---| | 1 | Set frame | `set_rect(id, &Rect)` `K/backend/mod.rs:325`; `KWinBackend::set_rect` `K/kwin/mod.rs:852-857` | `Window::set_position(&Rect, top)` `W/window.rs:374`; `WindowsApi::position_window` `W/windows_api.rs:501-555` (SetWindowPos `:639-652`); `move_window` `:655-666` | `Window::set_position(&Rect)` `M/window.rs:915`; direct path `set_position_direct` = `set_point` then `set_size`, two AX writes `M/window.rs:1050-1058, 1148-1184`; animated path `animator::retarget` `M/window.rs:1061-1082` | **KDE: queued.** A `geo` command is pushed (`command_rect` `K/kwin/mod.rs:786-788`) and carried out as the answer to a held `Poll` (`:268-300`, 1 ms coalescing `:141`); the requested rect is written into the table at once (`K/kwin/state.rs:596-600`). **Windows: sync by default** (`WINDOW_HANDLING_BEHAVIOUR` default `Sync`, `W/lib.rs:266-267`, `W/core/mod.rs:816-822`); with `Async` and `with_async_window_pos` the call adds `ASYNC_WINDOW_POS` (`W/windows_api.rs:521-528`). **macOS: sync AX round trips** (`M/animation/animator.rs:6-7`) when animation is off; queued to the animator lane when on. Rect: Windows adds the DWM shadow offset before the call (`W/windows_api.rs:534-540`, `shadow_rect` `:808-821`); KDE sets `frameGeometry` (`K/kwin/bridge.js:378-381`); macOS writes AX position and size as written. A client may refuse the size (documented for KDE `K/backend/mod.rs:319-320`; macOS reads it back, `M/arrival.rs:1-12`). Errors: KDE only for an unknown or dead id (`K/kwin/mod.rs:797-806`); Windows returns the `SetWindowPos` error (`.process()` `:651`); macOS returns the AX error and a failed write asks the reaper whether the window is gone (`M/window.rs:1155-1162`, `M/reaper.rs:164-173`). | | 2 | Get frame | `window_rect(id)` (provided) `K/backend/mod.rs:617-619` over `window(id)` `:245` | `WindowsApi::window_rect(hwnd)` `W/windows_api.rs:789-802` | `MacosApi::window_rect(&AXUIElement) -> CGRect` `M/macos_api.rs:385-427` | KDE: from the daemon's table, never waits on KWin; holds the optimistic requested rect until a `geometry` event replaces it (`K/kwin/state.rs:594-600`). Windows: **visible bounds** (`DWMWA_EXTENDED_FRAME_BOUNDS`, without the shadow) with fallback to `GetWindowRect` (includes shadow) (`:792-801`). macOS: AX position and size, two sync IPC calls, errors logged and returned (`:386-410`). macOS takes an **element, not an id**. | | 3 | Focus | `focus(id, mouse_follows_focus)` `K/backend/mod.rs:332`; `K/kwin/mod.rs:859-880` | `Window::focus` `W/window.rs:591-622` -> `WindowsApi::raise_and_focus_window` `W/windows_api.rs:722-747` | `Window::focus` `M/window.rs:1084-1139` | KDE queues an `activate`, then (if mouse follows) spawns a task that polls up to 60 x 5 ms for the window to be foreground before moving the pointer (`:864-877`). Windows: a synthetic `SendInput` to pass the foreground lock, `SetWindowPos` (error ignored), then `SetForegroundWindow`, whose failure is the returned error; skips the work when already foreground (`W/window.rs:599-607`). macOS: tries the private SkyLight `set_front_process`, else `NSRunningApplication::activateWithOptions` (`M/window.rs:1089-1102`, `M/skylight.rs:206`), then sets `AXMain` (`:1131`); tabbed apps use `main_window()` (`:1105-1129`). Pointer centring reads the frame back over AX. | | 4 | Raise | `raise(id)` `K/backend/mod.rs:339`; `K/kwin/mod.rs:882-884` | `Window::raise` `W/window.rs:791-798` -> `raise_window` `W/windows_api.rs:563-583` | `Window::raise` `M/window.rs:1141-1146` | Windows raises without activating (`SetWindowPos(HWND_TOP, NOACTIVATE)`) and also raises the window's border. macOS has **no raise-without-focus**: it sets `AXMain` and `AXFocused` (`:1144-1145`). | | 5 | Minimize / unminimize | `minimize(id)`, `unminimize(id)` `K/backend/mod.rs:368, 375`; `K/kwin/mod.rs:972-978` | `Window::minimize` `W/window.rs:556-561` (skips an exe containing `komorebi-bar`) -> `minimize_window` `W/windows_api.rs:686`; unminimize is `restore_window` (`SW_SHOWNOACTIVATE`) `:706-708` | `Window::minimize`/`unminimize` set `AXMinimized` true/false `M/window.rs:794-805` | Windows has no separate unminimize, and `show_window` ignores the result (`W/windows_api.rs:668-684`, "TODO: error handling"; `ShowWindowAsync` when `Async`), so these return `()`. KDE and macOS return `Result`. | | 6 | Hide / restore (back of a stack, other workspace) | `hide(id)`, `restore(id)` `K/backend/mod.rs:353, 361`; `K/kwin/mod.rs:886-925` | `Window::hide_with_border`/`restore_with_border` `W/window.rs:488-554` | `Window::hide`/`hide_on` `M/window.rs:602-676`, `restore` `:807-829` | **Three different mechanisms.** KDE: the window is moved to an extra virtual desktop `komorebi-park` that nobody looks at; it stays alive, minimized-false, on its workspace (`K/kwin/mod.rs:55-61` module doc, `K/backend/mod.rs:32-38`). Windows: by `HidingBehaviour`: `Hide` (`SW_HIDE`), `Minimize`, `Cloak` (the undocumented `SetCloak` through COM, `W/com/mod.rs:68-`); **default `Cloak`** (`W/lib.rs:205-206`); komorebi keeps `HIDDEN_HWNDS` (`W/lib.rs:89`, `W/window.rs:495-500`) so it does not take its own hiding for the user's. macOS: the window is **moved to leave a 1-point sliver in a display corner** (`M/lib.rs:334-348`) after its restore rect is stored in the static `WINDOW_RESTORE_POSITIONS` (`M/lib.rs:121`, `M/window.rs:616-676`); restore rewrites position and size. A hidden macOS window is an ordinary window at another position, so the app and the user see it move (observers report it; `PARKED_WINDOWS` bookkeeping `M/window.rs:1152`). | | 7 | Close | `close(id)` `K/backend/mod.rs:382`; `K/kwin/mod.rs:980-982` | `Window::close` `W/window.rs:563-565` -> `close_window` posts `WM_CLOSE` `W/windows_api.rs:694-700` | `AdhocWindow::close(&AXUIElement)` presses the AX close button `M/window.rs:1444-1453`, called on the foreground element `M/process_command.rs:327-332` | All three are requests, not guarantees. macOS returns `Ok(())` when the window has no close button (`:1451`). macOS closes the **foreground element**, not a stored `Window`. | | 8 | Alive check | `is_window(id)` (provided, `window(id).alive`) `K/backend/mod.rs:612-614`; a destroyed window stays queryable with `alive == false` for a while `:18-22` | `WindowsApi::is_window` (`IsWindow`) `W/windows_api.rs:1090`; the reaper polls it every 20 ms `W/reaper.rs:173-210` | `Window::is_valid` = `copy_attribute_names` returns something `M/window.rs:572-574` | KDE: table lookup, never waits. Windows: kernel call, no app involvement, polled without the WM lock (`W/reaper.rs:173-210`). macOS: an AX round trip to the owning app, only driven on mouse-up/key-up from the event tap (`M/input_event_listener.rs:79-82`, `M/reaper.rs:84-93`) and after failed AX writes (`M/reaper.rs:164-173`): macOS has no pollable "is this window gone". | | 9 | Foreground window | `foreground_window() -> Option` `K/backend/mod.rs:248`; `K/kwin/mod.rs:818-820` | `WindowsApi::foreground_window() -> Result` `W/windows_api.rs:718-720` | `MacosApi::foreground_window_id() -> Option` `M/macos_api.rs:429-444`; `foreground_window() -> Option` `:446-456` | KDE: table. Windows: `GetForegroundWindow`; a null handle is an `Err`. macOS: AX system-wide -> focused application -> focused window, then `_AXUIElementGetWindow` (private, `M/accessibility/private.rs:12-16`); `None` whenever any AX step fails; sync IPC. | | 10 | Window list | `windows() -> Vec` `K/backend/mod.rs:242`; `K/kwin/mod.rs:810-812` | `WindowsApi::load_workspace_information` `W/windows_api.rs:437`, `enum_windows` `:433` (callbacks `W/windows_callbacks.rs`) | `MacosApi::load_workspace_information` `M/macos_api.rs:312-374` over `CoreGraphicsApi::window_list_info` `M/core_graphics/mod.rs:126-133` | KDE returns every candidate window with all fields (`WindowInfo` `K/backend/mod.rs:63-91`). Windows and macOS only enumerate at startup and learn the rest from events. **macOS joins two worlds by title**: CG gives window ids and names, AX gives elements, and the match is `window_by_title` (`==` or `contains`) (`M/application.rs:195-208`, `M/macos_api.rs:346`). | | 11 | Monitors and work areas | `monitors() -> Result>` `K/backend/mod.rs:255`; `K/kwin/mod.rs:830-836` | `WindowsApi::load_monitor_information` `W/windows_api.rs:292`, `monitor(hmonitor)` `:1126-1166` | `MacosApi::latest_monitor_information` `M/macos_api.rs:212-309`, `load_monitor_information` `:96`, `update_monitor_work_areas` `:182` | KDE: table, logical pixels, `Err` when empty (`:831-834`). Windows: `win32_display_data`, physical pixels (process is PerMonitorV2, `W/main.rs:223`, `W/windows_api.rs:1169-1172`), `id: isize` (`W/monitor.rs:33`). macOS: **live** query of `NSScreen`, CoreGraphics and IOKit (`:213-221`), main-thread only (`:213`), `id` is the `CGDirectDisplayID`; work area is `NSScreen.visibleFrame` flipped into Quartz coordinates (`:275-291`). | | 12 | Monitor from point | `monitor_from_point(x, y)` (provided) `K/backend/mod.rs:622-628` | `WindowsApi::monitor_from_point` `W/windows_api.rs:492-496` | `CoreGraphicsApi::display_with_point` `M/core_graphics/mod.rs:102-123`, `MacosApi::monitor_from_point` `M/macos_api.rs:481-483` | KDE and macOS return `None` outside every monitor; Windows uses `MONITOR_DEFAULTTONEAREST` so it **never fails** (`:493`). KDE reads `size.left + size.right` (origin plus width) (`:624-625`). | | 13 | Cursor position | `cursor_pos() -> Option<(i32,i32)>` `K/backend/mod.rs:258`; `K/kwin/mod.rs:838-850` | `WindowsApi::cursor_pos() -> Result` `W/windows_api.rs:847-852` | `MacosApi::cursor_pos() -> CGPoint` `M/macos_api.rs:475-479` | KDE is the odd one: it asks the KWin script and **blocks the caller up to 250 ms** (`:846`), falling back to the last position seen; Windows and macOS read it directly. | | 14 | Center cursor | `center_cursor_in(&Rect)` `K/backend/mod.rs:389`; `K/kwin/mod.rs:991-1001` | `WindowsApi::center_cursor_in_rect` `W/windows_api.rs:862-864` | `MacosApi::center_cursor_in_rect` `M/macos_api.rs:376-381` | **KDE ignores the rect**: KWin can only centre on the active window, so the call is correct only right after focusing that window (`:992-993`). Windows and macOS centre on the rect (`left + right/2`, width halved). KDE queues; the other two are sync. | | 15 | Set wallpaper | `set_wallpaper(monitor_id, &Path)` `K/backend/mod.rs:586`; `K/kwin/mod.rs:1050-1084` | `WindowsApi::set_wallpaper(path, hmonitor)` `W/windows_api.rs:1488-1510` | `MacosApi::set_wallpaper(path, display_id)` `M/macos_api.rs:56-91` | KDE: validates the monitor and the file, then a task asks Plasma and retries; returns at once. Windows: **sync** COM `IDesktopWallpaper`. macOS: `exec_async` on the main queue and `Ok(())` regardless (`:62, 90`; failures only logged `:83`). | | 16 | Maximize | `maximize(id, bool)` (provided, default no-op) `K/backend/mod.rs:607`; `K/kwin/mod.rs:984-989` | `Window::maximize`/`unmaximize` `W/window.rs:567-589` -> `W/windows_api.rs:710-716` | **none**: `Workspace::maximized_window` exists (`M/workspace.rs:52, 124`) but is never assigned `Some`; `ToggleMaximize` is commented out (`M/core/mod.rs:321`) | The "maximized" state query is also generic: `WindowInfo::maximized` (KDE) and `is_zoomed` (Windows, 9 sites). | | 17 | Opacity | `set_opacity(id, u8)` (provided, default no-op) `K/backend/mod.rs:529`; `K/kwin/mod.rs:1017-1022` | `Window::transparent`/`opaque` `W/window.rs:625-`, `set_transparent` `W/windows_api.rs:1346-1358` | **none**: transparency config is commented out (`M/static_config.rs:535-541`); `kCGWindowAlpha` is read only to filter windows (`M/window.rs:1547`) | Both implementations take a `u8` alpha (KDE divides by 255, `:1020`). | | 18 | Workspaces / desktops | five methods `ensure_workspaces`, `switch_workspace`, `set_window_workspace`, `window_workspace`, `current_workspaces` `K/backend/mod.rs:408-432` | **none in the OS**: workspaces are komorebi's own, made visible by hide/restore (row 6) | **none in the OS**: komorebi's own; a guard ignores events and commands while the macOS Space is not the managed one (`M/process_event.rs:120-140`, `M/lib.rs:184`) | KDE alone delegates workspaces to the compositor (virtual desktops, per output, `K/kwin/mod.rs:47-54`). The shared core cannot call these five on Windows or macOS; it needs a capability query or a split (section 7, consequence 3). | | 19 | Focus follows mouse | `set_focus_follows_mouse(bool)` (provided, default no-op) `K/backend/mod.rs:553`; rewrites `kwinrc` `K/kwin/mod.rs:1024-1048` | `enable_`/`disable_`/`focus_follows_mouse` `W/windows_api.rs:1224-1257` (system setting) plus a komorebi implementation on its own thread `W/process_movement.rs:14-60` | **none** (finding 9 above) | KDE and Windows each ask the OS to do it; Windows also has its own mouse-hook implementation. | | 20 | Window identity fields | `WindowInfo` fields `pid`, `title`, `class`, `exe`, `path` `K/backend/mod.rs:63-75` | `window_thread_process_id` `W/windows_api.rs:866-879`, `window_text_w` `:1004`, `real_window_class_w` `:1052`, `exe`/`exe_path` `:1031-1050` (each a separate call) | `Window::title/exe/path/bundle_identifier/role/subrole` `M/window.rs:833-905`; no window class, a bundle identifier instead | KDE delivers them in one snapshot with the window; Windows asks per field (the hook callback comments on the cost, `W/windows_callbacks.rs:197-203`); macOS asks the app per field over AX. | ### 2.2 Platform subsystems (one platform, or the same name with unrelated implementations) | Subsystem | Windows | KDE | macOS | |---|---|---|---| | Borders | own `WS_EX_TOPMOST` windows each on a thread with a message loop `W/border_manager/border.rs:304-340`, `W/windows_api.rs:1322-1344` | **delegated to the compositor** through `Backend::apply_look`, `set_border_colours` `K/backend/mod.rs:473, 504`; `K/kwin/effects.rs` | one `NSWindow` per border created on main (`exec_async` `M/border_manager/ns_window.rs:53`), AX observers per border `M/border_manager/border.rs:153-170`; thread `M/border_manager/mod.rs:323` | | Stackbars | `W/stackbar_manager/` (windows with their own message-loop thread `W/stackbar_manager/stackbar.rs:117-150`) | none | none | | Animation | ghost windows with DWM thumbnails `W/animation/ghost.rs:1-14`, `W/animation/engine.rs`; dwm_* fns | `Look::animation` is a request to the compositor `K/backend/mod.rs:141-152` | animator thread plus a lane thread per app pid `M/animation/animator.rs:122, 597`; `NSWindow` ghosts `M/animation/ghost.rs:125-142` | | Device / power / session notifications | hidden window with `WTSRegisterSessionNotification`, power and device notifications `W/monitor_reconciliator/hidden.rs:60-110`, `W/windows_api.rs:1410-1426, 1484` | `K/kwin/power.rs:60-72` (logind and screen-lock over D-Bus) | `NSWorkspace` notifications `M/notification_center_listener.rs:183-229`; CG display callback `M/display_reconfiguration_listener.rs:12-30, 76` | | Window-event source | `SetWinEventHook` on a message-pump thread `W/winevent_listener.rs:24-56` | the KWin script reports over D-Bus `K/kwin/mod.rs:228-255` | AX observers and `NSWorkspace` on the main run loop (section 3.3) | | Raw input | mouse hook via `winput` `W/process_movement.rs:14-20` | KWin global shortcuts `K/kwin/hotkeys.rs` | `CGEventTap` `M/input_event_listener.rs:63-160` | | Private/undocumented OS calls | `SetCloak` COM `W/com/mod.rs:68-` | none found | SkyLight: `CGSGetActiveSpace` `M/lib.rs:184`, `SLSDisableUpdate`/`SLSReenableUpdate` batching `M/skylight.rs:18-75`, `_SLPSSetFrontProcessWithOptions` `M/skylight.rs:123, 206`; `_AXUIElementGetWindow` `M/accessibility/private.rs:12-16` | | Pan gestures | `W/pan.rs` | none | `M/pan.rs` (508 lines) | | Compositor-only (KDE) | | rounded-corner effect, kwinrc editing, hotkey daemon (`K/kwin/effects.rs`, `K/kwin/kwinrc.rs`, `K/kwin/hotkeys.rs`) | | | Window style edits, title-bar removal, DWM accents | `update_style`, `remove_title_bar`, `set_window_accent`, `round_corners` `W/window.rs:707-790`, `W/windows_api.rs:985-1002, 1295-1320` | none | none | ### 2.3 Re-measured counts Method (reproducible from the repo root). Windows: every `WindowsApi::` occurrence in `komorebi/src` outside `windows_api.rs`, lines that are `//` comments dropped, trailing `//` comments cut; plus `komorebi-bar/src`. macOS: the same for `MacosApi::`, `CoreGraphicsApi::`, `AccessibilityApi::` in `komorebi-for-mac/komorebi/src` outside `macos_api.rs`, `core_graphics/mod.rs`, `accessibility/mod.rs`. (A naive `grep` over-counts: `M/window_manager.rs:490-492, 2489` are commented-out `MacosApi::` calls.) | API | Distinct fns used outside the API file | Call sites | Defined in the API file | |---|---|---|---| | `WindowsApi` | 71 | 280 in `W/` + 3 in `komorebi-bar/src/bar.rs` = 283 | 92 `pub fn` lines (some duplicated under `cfg`) | | `MacosApi` | 14 | 78 | 14 | | `CoreGraphicsApi` | 5 | 13 | 8 (+1 free fn `display_for_frame` `M/core_graphics/mod.rs:143`) | | `AccessibilityApi` | 13 | 67 (33 in `M/window.rs`, 11 in `M/application.rs`, 4 each in `M/animation/animator.rs`, `M/border_manager/border.rs`, `M/process_event.rs`, rest 1-2 each) | 13 | | KDE `Backend` | 31 methods = 19 required + 12 provided (28 primitives + 3 derived) | 73 `backend()` call sites outside `K/backend/` | n/a | Split rule. A function is **generic** when the operation it performs has a counterpart on at least one other platform (a KDE `Backend` method or a macOS function in the table above). It is split in two tiers because the boundary is a judgement: - G1 (strict): the operation is in section 2.1. - G2: a window-state read or z-order helper with no counterpart today but that a shared `WindowInfo` or `Backend` could carry (`lower_window`, `bring_window_to_top`, `is_window_visible`, `is_window_cloaked`, `monitor_from_window`, `get_transparent`, `process_handle`, `close_process`, `window_at_cursor_pos`). - Platform-only (W / P): everything else (class registration, DWM thumbnails, GWL styles, notification registration, raw AX primitives, ...). | Platform | G1 fns / sites | G2 fns / sites | Platform-only fns / sites | |---|---|---|---| | Windows (71 fns, 283 sites) | 32 / 196 | 9 / 23 | 30 / 61 | | macOS (`MacosApi` + `CoreGraphicsApi` + `AccessibilityApi`: 32 fns, 158 sites) | 15 / 83 | 1 / 4 (`left_mouse_button_is_pressed`) | 16 / 71 (13 raw AX primitives, `frontmost_process_id`, `activate_finder`, `contains_rect`) | Windows G1 + G2 = 41 fns / 219 sites (earlier survey 42 / 209); platform-only = 30 / 61 (earlier 29 / 70). The per-function counts are in 2.4 so that the split can be re-derived with another rule. What the macOS count says about the seam: 67 raw AX call sites live outside `accessibility/mod.rs`, 33 of them in `M/window.rs` and 11 in `M/application.rs`; `M/macos_api.rs` itself has only 6. Most of the macOS seam is therefore the `Window` and `Application` types, not the `*Api` structs, which is why step 6 normalises `Window` methods first. ### 2.4 Per-function counts (name:sites) Windows, `WindowsApi::` outside `windows_api.rs` (class in brackets: G1, G2, W): - G1: window_rect:39, foreground_window:26, is_window:21, restore_window:16, position_window:15, is_zoomed:9, disable_focus_follows_mouse:6, center_cursor_in_rect:6, real_window_class_w:5, raise_and_focus_window:5, monitor:4, is_iconic:4, focus_follows_mouse:4, enable_focus_follows_mouse:4, window_thread_process_id:3, maximize_window:3, hide_window:3, close_window:3, unmaximize_window:2, set_transparent:2, raise_window:2, minimize_window:2, load_monitor_information:2, cursor_pos:2, window_text_w:1, set_wallpaper:1, move_window:1, monitor_rects:1, monitor_from_point:1, load_workspace_information:1, exe_path:1, exe:1 - G2: is_window_visible:6, is_window_cloaked:4, window_at_cursor_pos:2, process_handle:2, monitor_from_window:2, lower_window:2, get_transparent:2, close_process:2, bring_window_to_top:1 - W: module_handle_w:8, register_class_w:6, dwm_update_thumbnail_properties:5, dwm_unregister_thumbnail:4, desktop_window:4, register_device_notification:3, dwm_register_thumbnail:3, create_solid_brush:3, update_style:2, update_ex_style:2, set_window_accent:2, wts_register_session_notification:1, set_process_dpi_awareness_context:1, set_border_pos:1, register_power_setting_notification:1, process_id_to_session_id:1, monitors_have_same_dpi:1, monitor_info_w:1, left_click:1, invalidate_rect:1, gwl_style:1, gwl_ex_style:1, foreground_lock_timeout:1, enum_windows:1, enum_display_monitors:1, dpi_for_monitor:1, current_process_id:1, create_hidden_window:1, create_border_window:1, allow_set_foreground_window:1 macOS, outside the API files (G1, G2, P): - G1: MacosApi::window_rect:39, MacosApi::foreground_window_id:14, MacosApi::foreground_window:7, MacosApi::center_cursor_in_rect:3, MacosApi::load_monitor_information:2, MacosApi::cursor_pos:2, MacosApi::update_monitor_work_areas:1, MacosApi::set_wallpaper:1, MacosApi::monitor_from_point:1, MacosApi::load_workspace_information:1, MacosApi::latest_monitor_information:1, CoreGraphicsApi::display_bounds_for_window_rect:5, CoreGraphicsApi::display_bounds:4, CoreGraphicsApi::window_list_info:1, CoreGraphicsApi::connected_display_ids:1 - G2: MacosApi::left_mouse_button_is_pressed:4 - P: MacosApi::frontmost_process_id:1, MacosApi::activate_finder:1, CoreGraphicsApi::contains_rect:2, AccessibilityApi::copy_attribute_value:17, AccessibilityApi::window_id:11, AccessibilityApi::set_attribute_cf_value:9, AccessibilityApi::set_attribute_ax_value:8, AccessibilityApi::set_messaging_timeout:6, AccessibilityApi::invalidate_observer:3, AccessibilityApi::create_observer:3, AccessibilityApi::copy_attribute_names:3, AccessibilityApi::add_observer_to_run_loop:3, AccessibilityApi::remove_notification_from_observer:1, AccessibilityApi::perform_action:1, AccessibilityApi::create_application:1, AccessibilityApi::add_notification_to_observer:1