mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-11-18 22:58:34 +01:00
komorebi-core gets Monitor<P: MonitorPlatform> (MonitorPlatform extends WorkspacePlatform), moved from komorebi-for-kde/komorebi/src/monitor.rs and made generic: the id and serial_number_id are the platform's associated types (Id with serialize_id/deserialize_id hooks so each daemon keeps writing its id as the plain number it always did; SerialNumber), and the fields only a platform has are P::Extra, flattened into the monitor's JSON (NoExtra for a platform with none). The schema is named Monitor. The workspace accessors (impl_ring_elements! is not generic) are written out, and eight functions move with them: focused_workspace_layout, focused_workspace_name, new_workspace_idx, ensure_workspace_count, remove_workspaces, remove_workspace_by_idx, add_container and focus_workspace, the last taking the name the platform last knew for a new workspace from the known_workspace_name hook (Windows keeps its names in the extra fields). WorkspacePlatform now needs Clone, Debug and PartialEq of the platform marker and ContainerWindow needs Debug, because the derives on the generic structs ask for them. One serde fact the tests pin: a flattened map is read through a buffer that keeps its keys as strings, so an extra field with integer keys (the Windows workspace_names) needs a deserialize_with that parses them; the Windows converge must carry it. Tests with stub platforms: the JSON of a monitor with flat extra fields and the id as a number, a monitor without extra fields, the name hook of focus_workspace, the schema name and flat properties. Verified: cargo test -p komorebi-core --features schemars (native): 27 passed, 0 failed; Windows clippy --workspace --locked --all-targets -D warnings: PASS. Not run: the daemons.