mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-12-05 06:26:30 +01:00
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.
45 lines
1.8 KiB
Rust
45 lines
1.8 KiB
Rust
//! What every komorebi daemon asks of its platform.
|
|
//!
|
|
//! The window manager logic should talk to a [`Backend`], never to KWin, Win32 or the macOS
|
|
//! Accessibility API. This crate holds the vocabulary of that conversation and nothing that
|
|
//! belongs to one platform:
|
|
//!
|
|
//! - [`WindowId`] and [`MonitorId`], the names a backend gives windows and monitors;
|
|
//! - [`WindowInfo`] and [`MonitorInfo`], plain data, with an [`Option`] for everything that is
|
|
//! not available on every platform;
|
|
//! - [`Error`], which can say that "the window is gone" and that "this platform cannot do that";
|
|
//! - the [`Backend`] trait, with only the operations that at least two platforms have
|
|
//! (`docs/dev/seam.md`, section 2.1), a [`Capability`] query for the ones only some platforms
|
|
//! have, and a [`Batch`] scope for writes that should appear together;
|
|
//! - [`fake::FakeBackend`], an in-memory desktop with failure injection and frame offsets,
|
|
//! and [`contract`], the checks that every backend has to pass.
|
|
//!
|
|
//! The evidence for each choice, and the status of every claim (confirmed, corrected or target),
|
|
//! is in `docs/dev/seam.md`. The doc comment of each item says which platforms implement it.
|
|
//!
|
|
//! # Platform-specific operations
|
|
//!
|
|
//! Borders and their colours, the look, the wallpaper, drag origin and end frames, stackbars,
|
|
//! observers and event taps are not here: they are one platform's business and live in that
|
|
//! platform's own trait or crate (for KDE, `komorebi::backend::Backend` still has them).
|
|
|
|
#![deny(missing_docs)]
|
|
|
|
mod backend;
|
|
pub mod contract;
|
|
mod error;
|
|
pub mod fake;
|
|
mod id;
|
|
mod info;
|
|
|
|
pub use backend::Backend;
|
|
pub use backend::Batch;
|
|
pub use backend::Capability;
|
|
pub use error::Error;
|
|
pub use error::Result;
|
|
pub use id::MonitorId;
|
|
pub use id::WindowId;
|
|
pub use info::MonitorInfo;
|
|
pub use info::WindowInfo;
|
|
pub use komorebi_layouts::Rect;
|