Repository navigation
feat(platform): add bitty-platform crate skeleton with owned winit event adapter - #20
Merged
Merged
Conversation
…ent adapter Implements CarryCtx task CTX-0014 (GitHub issue #17) per the ADR-0003 crate graph row (bitty-platform: window/event-loop adapter, DPI; no workspace deps) and the ADR-0004 decision row adopting winit ~0.30.x inside bitty-platform with crossterm rejected as a runtime input path. - Strictly owned public API: no winit type escapes the crate; internal ApplicationHandler adapter translates WindowEvent streams into the owned PlatformEvent/WindowEventKind vocabulary (resized, DPI scale factor, redraw, focus, keyboard, mouse button/wheel, cursor motion, close-requested/closed) plus loop resumed/suspended/about-to-wait/ exiting phases. - DPI-aware owned types: ScaleFactor (validated finite > 0), LogicalPixel, LogicalSize, PhysicalSize with deterministic round-half-away-from-zero conversions and saturating physical rounding. - Owned keyboard model over logical keys (terminal-relevant NamedKey subset with documented Other collapse; positional KeyCodes deferred to the open input-domain placement question in ADR-0003), text/location/ state/repeat/synthetic flags; synthetic focus events are dropped. - Headless-friendly test seam: field-level translation functions unit- tested without a display; winit event-loop main-thread constraint handled by a dedicated harness=false integration target verifying graceful PlatformError::DisplayUnavailable degradation headlessly and clean exit with a display; display-dependent window tests gated behind the default-off gui-tests feature and documented as not run in CI. - #![forbid(unsafe_code)]; no render/grid/business coupling; workspace manifest change limited to one members-list line for CTX-0015 union merge; Cargo.lock gains the winit 0.30.13 tree. just check green locally (fmt-check, clippy -D warnings --locked, test --locked incl. headless_run entry point, actionlint, markdownlint). Closes #17 Refs: CTX-0014
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements CarryCtx task CTX-0014. Closes #17.
Contract outcome
bitty-platformrow of the accepted ADR-0003 crate graph (window/event-loop adapter + DPI; depends on no other workspace crate) and the ADR-0004 decision row: ADOPT winit (~0.30.x) inside bitty-platform; crossterm stays rejected as a runtime input path. Locked to winit 0.30.13 via Cargo.lock (single-pin rule).Public API (strictly owned; no winit type escapes)
App::run(AppHandler)— drives the OS event loop; returns ownedPlatformError::DisplayUnavailableheadlessly instead of panicking.AppHandler::handle_event(&mut EventContext, PlatformEvent)— single delivery point;EventContextexposescreate_window(WindowConfig) -> WindowHandle,exit,set_poll,set_wait.PlatformEvent:Window { window_id, kind }plusResumed/Suspended/AboutToWait/Exiting.WindowEventKind(owned translation of winit window events):Resized(PhysicalSize),ScaleFactorChanged(ScaleFactor),RedrawRequested,Focused(bool),KeyboardInput(KeyEvent),MouseInput(MouseEvent),MouseWheel(ScrollDelta),CursorMoved(CursorPosition),CursorLeft,CloseRequested,Closed.ScaleFactor(validated finite > 0, sanitized fallback),LogicalPixel,LogicalSize,PhysicalSize; deterministic round-half-away-from-zero conversions, saturating at u32::MAX.LogicalKey::{Character, Named(NamedKey), Dead, Unidentified}; terminal-relevantNamedKeysubset with documented collapse-to-Other for the rest; positional KeyCodes deliberately deferred to the open input-domain placement question in ADR-0003. Synthetic focus-change key events are dropped during translation.WindowId(u64)values; winit's opaque ids stay internal.Headless-friendly test seam (CI has no display)
translate_key_parts,map_*) are unit-tested without a display because several upstream payloads (DeviceId,InnerSizeWriter,KeyEvent.platform_specific) are not constructible off-platform.tests/headless_run.rstarget withharness = falseruns as a real process entry point (winit requires main-thread loop creation): asserts owned-error degradation headlessly and clean exit with a display. Not verifiable in CI: actual GPU/compositor present-path behavior.tests/display.rsbehind the default-offgui-testsfeature; never run in CI, documented in-file.Safety / security
\#![forbid(unsafe_code)]— no exception claimed; consuming winit 0.30 requires none.Manifest note
Workspace root change is exactly one members-list line (+ lockfile) so CTX-0015's parallel edits union-merge cleanly.
Validation
just checkgreen — fmt-check, clippy --workspace --all-targets --locked -D warnings, test --workspace --all-targets --locked (24 unit tests + headless_run entry point), actionlint, markdownlint.Refs: CTX-0014