Source: gpui-ce/gpui-ce at 1fe3d947698287f3ba50ef074a3eadd1ad46b84c, verified against a local checkout of that exact commit. This is a static source trace, not a build, benchmark, or claim that the proposed framework matches upstream. Verified paragraphs describe upstream; First-edition reading paragraphs distinguish the transferable idea from complexity to leave out. These are reference notes, not the implementation plan.
Across the six areas, the common boundary is: native event → normalized input → framework update → frame demand → layout, prepaint, paint → committed frame → presentation. Keyboard can force a synchronous draw before routing, and expose can request presentation without a new draw. Those are different operations, not exceptions to the distinction between updating the framework and showing pixels.
1. Linux/X11: application, window, and event loop
Verified — select and start the backend. gpui_platform::application / current_platform wrap the selected Platform in an Application; Linux delegation reaches gpui_linux::current_platform. guess_compositor considers build features and environment: ZED_HEADLESS, then nonempty WAYLAND_DISPLAY, then nonempty DISPLAY, then headless. This is detection, not a failed-connect retry; once X11 is selected its constructor is unwrapped. Application::run passes the startup closure to LinuxPlatform::run, which runs it before X11Client::run takes its calloop loop and runs it with no timeout.
Verified — create and register, then map. App::open_window reserves a framework ID (see §2), then Window::new calls the platform. LinuxPlatform::open_window delegates to X11Client::open_window, which allocates an XID, constructs the window and registers it by XID as initially unmapped. The native setup creates the XCB window with device-pixel bounds and core expose/structure/focus/key/property/visibility masks; it then registers WM_DELETE_WINDOW and sync, selects XI2 pointer events and creates WgpuRenderer on the raw XCB window. Core Window::new installs callbacks before calling map_window; X11 maps only if visible.
Verified — what drives the loop. X11Client::new creates the loop and channels, schedules foreground runnables as idle callbacks behind input callbacks, opens the XCB connection, and negotiates XI2. It selects XKB notifications and initializes keyboard/compose state, resources and optional XIM, then registers the XCB FD for level-triggered reads. process_x11_events polls until drained, folds duplicate exposes into a window-ID set, handles repeat-pair suppression and keymap changes, dispatches events (via XIM filtering when present), then requests presentation once per exposed, mapped window in that drain batch. handle_event updates the refresh loop on map/unmap/visibility. update_refresh_loop / start_refresh_loop run a periodic timer while mapped and not fully obscured. The timer calls X11WindowStatePtr::refresh without requiring presentation, and also drains X11 events. Thus a timer tick is a request, not proof that any redraw or present occurred.
Verified — translate and deliver. handle_event routes ConfigureNotify to set_bounds, which updates logical bounds and drawable extent and calls resize; FocusIn/Out changes native window activation and client keyboard focus. Core X key events become KeyDown/Up via XKB; XI2 input produces mouse/scroll input with window-local coordinates divided by scale. handle_input invokes the registered Window::dispatch_event callback; unconsumed printable key-down can fall through to the platform text handler. The close client-message path checks should_close, then invokes close, whose core callback marks the window removed. App::update_window_id removes that window; native destruction destroys renderer/window and schedules client-table/timer cleanup.
First-edition reading. Retain native ownership/lifecycle and the normalized event/frame-request boundary; do not copy the production loop merely to match GPUI. Multi-backend discovery, desktop portals, XIM/compose, window-manager sync and decorations, XI2 smooth scrolling/gestures, and refresh-rate discovery are separable from the core trace.
2. Window draw: root, layout, prepaint, paint, present
Verified — first and later frames. App::open_window builds and stores a root Entity<V: Render> and draws once before returning; it does not present inline. In Window::new's request-frame callback, pending next-frame callbacks run first. Dirty or force-render calls draw then present. A clean window can present the existing scene when required, already pending, or driven by high-rate input; an idle request can do neither.
Verified — the root-to-scene chain. Window::draw_roots turns the root into an element. On the ordinary path, ViewElement::request_layout invokes the entity's Render::render, then requests the resulting element's layout. request_layout supplies rules/child IDs but has no final bounds; the viewport fills only the root's auto-size axes via stretch_auto_size_to_fill. prepaint_as_root computes the layout then prepaints at the supplied origin. The Element contract puts hitboxes in prepaint and primitives/listeners in paint; draw_roots recomputes the pointer hits on the new prepaint geometry before painting.
Verified — commit is not presentation. Window::draw prepares the next frame; it finishes and swaps next_frame and rendered_frame, clearing the old frame and marking presentation pending. Frame::finish carries forward accessed element state and finalizes the scene. For example, paint_quad snaps bounds and records a masked primitive, and Scene::finish sorts primitive collections and builds a render plan. Window::present passes the committed scene to X11Window::draw. WgpuRenderer::draw acquires a surface texture, encodes/submits the scene, and calls frame.present() only on success. rendered_frame is the latest framework commit, not confirmation a compositor showed it.
First-edition reading. Preserve the order and a scene/interaction snapshot boundary; a simple ordered command list can replace a GPU render plan. Taffy's full layout model, deferred overlays, subtree replay, arena management, filter targets, advanced batching, and device recovery are not prerequisites to the lifecycle. This trace does not verify accessibility parity.
3. Pointer hit testing versus keyboard/focus routing
Verified — pointer. Window::dispatch_event updates pointer state and resets propagation/default-prevention flags, then routes by input kind. Prepaint insert_hitbox_mut records bounds, content mask and behavior. Frame::hit_test scans in reverse insertion order; HitTest::new collects the front-to-back hits, distinguishes mouse-blocking from full occlusion, and honors the clip and disjoint inline fragments. dispatch_mouse_event hit-tests the committed frame, then walks that frame's listener list in registration order for capture and reverse for bubble, stopping when propagation is cleared. It is not a dispatch-tree ancestry walk; interactive elements decide which phases and hits they accept. A focusable Div's mouse-down listener checks hover and the default-prevention flag in bubble, takes focus, and prevents a parent from taking it away as a second default.
Verified — keyboard. Window::focus stores a FocusId, clears pending keystrokes, and refreshes; tab helpers consult the rendered tab stops. Prepaint set_focus_handle maps handles to dispatch nodes; key contexts are set during paint. Unlike pointer dispatch, dispatch_key_event first draws synchronously if dirty. Focus lookup falls back to the root; DispatchTree::dispatch_path walks actual parent links. DispatchTree::dispatch_key resolves bindings against the context path and tracks pending/replay for chords. Window::dispatch_key_event's tail tries matched actions unless character input is preferred and otherwise falls through to raw key/modifier dispatch if not consumed. Typed actions run global capture, node capture root→focus, node bubble focus→root, then global bubble if still propagating; matching bubble action handlers stop propagation by default.
First-edition reading. Make overlap, clip, pointer order and focus order observable. Native activation and element focus are separate states; a focus change need not move the pointer. A simplified pointer targeting/propagation contract, tab order and single-stroke action mapping can be explicit departures from GPUI. Chord timeouts/replay, keymap overlays, global action phases, touch, drag and IME composition need not come along with that contract.
4. Entity state, notification, and coalescing
Verified — mutation and notification are separate. Element module docs distinguish frame-local elements from durable entity state and state keyed by GlobalElementId. Entity<T>::update delegates to App::update_entity, which leases mutable state out of the entity map and returns it around the callback. That update path does not itself notify (the separate mutable borrow guard does on drop). Context<T>::notify sends the entity ID to App::notify.
Verified — find consumers and schedule work. The map logs entity reads/leases, Window::draw clears and collects accesses, and App::record_entities_accessed updates window/entity associations. App::notify filters invalidators to windows currently tracking the entity; no live invalidator queues a notify directly, otherwise it calls WindowInvalidator::invalidate_view. That method adds to the dirty-view set; outside drawing it sets the dirty bit, queues the notify effect and calls an available platform waker only on clean→dirty. During drawing it records the view ID without taking that same scheduling/effect branch. A later draw drains recorded IDs and marks ancestor views, so cache reuse can reject a dirty subtree. X11's periodic source does not rely on that optional waker.
Verified — distinct coalescing boundaries. App::finish_update flushes at the outermost update. push_effect / flush_effects deduplicate pending notify effects by entity and drain effects including newly queued work; apply_notify_effect removes the pending marker before invoking observers, so it is not a guarantee of once-per-flush observer execution. The window dirty bit independently combines work before a draw; draw clears it at its start. X11 expose deduplication, effect deduplication, and draw coalescing are three different mechanisms.
First-edition reading. Durable state, explicit invalidation, and one already-pending frame per dirty window are separable from reference-counted stores, dynamic dependency graphs, observation effects and subtree caching. If notification during draw isn't supported, define that boundary rather than silently dropping an update or inferring upstream's edge behavior.
5. Text: measurement and shaping versus rasterization
Verified — layout path on this pin. LinuxCommon::new constructs ParleyTextSystem::new(SwashGlyphRasterizer::default()) with system fonts and a fallback list. StyledText::request_layout delegates to TextLayout::layout, which registers a measured node. During Taffy measurement the closure receives logical constraints, derives wrapping/alignment options, calls WindowTextSystem::shape_text_with_options, and retains both the shaped document and its measured size. LineLayoutCache reuses geometry from the current/previous frame or calls platform layout_text on a miss. ParleyTextSystem::layout_text delegates to parley_layout, which splits multi-paragraph input, breaks shaped lines under the requested width, and extracts visual lines and positioned glyphs into paint fragments.
Verified — pixels come later. TextLayout::prepaint / paint save the resolved placement and paint the measured document. paint_text_fragment offsets placed glyphs from the baseline and uses run font ID/size. Window::paint_glyph / paint_glyph_from_atlas convert to device space, quantize origin, build raster parameters, and emit masked sprite primitives. WgpuAtlas::get_or_insert_glyph_with calls the raster builder on misses and stores an optional tile (empty glyphs need none). TextSystem::rasterize_glyph calls the platform rasterizer and validates the result; Parley resolves the stored font instance and delegates to Swash, which returns bitmap and baseline-relative placement. Measuring and painting share geometry, not bitmap dimensions.
First-edition reading. Keep measure/shape and glyph drawing distinct and test that they agree about placement. A bounded text contract and fixed font asset can exercise that seam without recreating Parley or Swash. Subpixel/color-emoji variants, font discovery/fallback breadth, full bidi/inline layout, complex editor caret navigation and atlas eviction are independent complexity.
6. Test context: deterministic seams, not native emulation
Verified — share core, substitute platform. TestAppContext::build / single construct real App with a TestPlatform, foreground/background executors backed by TestDispatcher, and fake HTTP. open_window calls the real app's open path at an explicit size. TestDispatcher uses seeded randomized scheduling; run_until_parked drains runnable work without advancing time; advance_clock is separate.
Verified — drive input, geometry and scheduling deliberately. VisualTestContext::simulate_event converts to PlatformInput, invokes TestWindow::simulate_input's registered window callback, then drains tasks. The one-keystroke helper instead calls the core Window::dispatch_keystroke directly. Simulated resize changes bounds and invokes the resize callback; Window::bounds_changed refreshes core viewport state. debug_bounds reads committed geometry; the nearby draw<E> helper lays out/paints an isolated element, not the whole app. There is also a test/bench-only App::flush_effects branch that draws dirty windows. Frame-request tests can deliver a scheduled frame explicitly; see the follow-up-frame test.
Verified — what the fakes cannot prove. TestPlatform::new defaults to deterministic TestTextSystem (synthetic glyph geometry and empty rasters), no renderer factory, and a stub atlas when no renderer is supplied. TestWindow::draw records frame demand and renders only if a renderer is configured. The window-scoped VisualTestContext is not the separate macOS-only VisualTestAppContext.
First-edition reading. Feed normalized input and explicit time/frame steps through the same core as the native demo. Inspect state, geometry, routing, commands and frame counts headlessly; verify real font/render output with fixed assets and native X11 lifecycle separately. Do not infer compositor behavior from a synthetic callback, pixel fidelity from fake glyphs, or deterministic timing from sleep-based tests.