gpui-cc Course handbook
AFTER THE CAPSTONE / EXTENSIONS

Future scope

Bring web-like UI capabilities to your native framework after the capstone.

On this page

After Stage 19, choose what you want to bring from the web:

  • Bring the behavior into C++. Build responsive layout, consistent styling, scrolling, and keyboard interaction on top of your own element tree, action dispatcher, and renderer. A typed theme is not the CSS cascade; a native element tree is not the DOM; a native action is not a DOM event. Use web specs to study individual behaviors, then write down the smaller contract your framework actually supports.
  • Run existing HTML, CSS, and JavaScript. Put a reviewed browser engine behind an optional adapter. The engine owns the document and executes the page; the native app owns the window or host, application state, and what the page may ask the host to do. Start with WebKitGTK on Linux; consider CEF only if you have a specific Chromium requirement. Neither path promises browser feature parity or lets you drop a website into the existing X11 paint list.

Start here: a native Settings Explorer

Make a third consumer of your C++20 library: an ASCII settings list with a selected setting’s details, a light/dark switch, and a few toggles. Seed it with 20 predictable rows. Keep settings and selection in the app model, use stable IDs for controls, and reuse the capstone focus and action machinery. Make themed and resizable without losing state the first project goal (releases 1–2 below). No text editor, browser, or GPU needed. Later releases extend this same app.

For each release, add a headless fixture against the real core and run a separate desktop smoke check for any new platform behavior. Keep the capstone regression checks green.

1. Typed styles and two themes

Build: Start with C++ theme structs for named colors, spacing, and text size. Pass the theme explicitly to controls and resolve styles from their existing states (normal, hovered, pressed, focused, disabled). This gives layout and paint shared inputs without a stylesheet parser, selectors, or inheritance. Start with light/dark palettes that share metrics.

Check: Toggle the theme with the keyboard. Assert that the recorded fill and focus-ring colors change but layout bounds, focus ID, and the selected setting do not.

Read: Design Tokens Format: types and aliases for naming and sharing values; it’s a Community Group report, not a required file format. CSS custom properties show what browser-side cascading variables do that your explicit theme does not.

2. Resize the list and detail panes

Build: Extend the existing row/column layout with a single-axis rule for a basis, a gap, minimum sizes, and weighted growth. With sufficient parent width, put list and detail side by side; below a documented threshold, stack them. Defer CSS flex shrinking, wrapping, and Grid until an app actually needs them.

Check: With a 200-unit list basis, 300-unit detail basis, a 16-unit gap, and all growth assigned to detail, a 700-unit inner width yields pane widths of 200 and 484. Test just below and at your breakpoint, with no overlap and the same focus and selection.

Read: CSS Flexbox: resolving flexible lengths. Borrow the idea of distributing free space, not the full algorithm.

If a later screen needs both row and column alignment: prototype explicit fixed and weighted tracks with cells addressed by row and column. Test shared column widths across rows when one label is longer, and keep keyboard traversal independent of visual rearrangement. Start with CSS Grid’s examples of track sizing; leave automatic placement and subgrid out until you need them.

3. Make one viewport scroll

Build: Give the settings list a vertical offset clamped to 0…max(0, content height − viewport height). Use the viewport clip and the same offset for painting and hit-testing. Add wheel input, a keyboard page action, and scroll-to-reveal when keyboard focus moves. Keep all 20 rows for now: validate geometry before optimizing it.

Check: With 600 units of content and a 180-unit viewport, stop at 420. A clipped row must not receive clicks outside the viewport. Tab to an offscreen control and check that its focus ring is brought into view.

Read: CSS Overflow: scroll containers and scrollports for the distinction between the content and the visible region.

4. Expose semantics to Linux assistive technology

Build: Before recycling rows, derive a small semantic tree from the same stable IDs and app state: name, role, state, parent/child order, bounds, focus, and actions. Start with buttons and toggles. Map it to Linux AT-SPI over D-Bus in the platform layer; send focus/state changes and dispatch accessible activation through the same action as mouse and keyboard. Web ARIA patterns are a behavior guide, not a substitute for this bridge.

Check: Assert the tree and state transitions headlessly. In a Linux desktop session with an accessibility bus and Orca, Tab to a toggle, verify its name and state are announced, and check that an AT-SPI action changes the same model value. A bare Xvfb run doesn’t establish screen-reader support.

Read: AT-SPI D-Bus interfaces, ARIA APG button and toggle-button behavior, and Orca user guide.

5. Virtualize a long list

Build: Scale the proven viewport to 10,000 fixed-height rows. Derive the visible index range from offset and row height; build only visible rows plus a small buffer on either side. Keep toggle state and selection by item ID, never by recycled slot. Keep focus traversal model-based: reveal and build a target before focusing it. Keep logical list position and count independent of what’s painted; verify the assistive-technology story before replacing the nonvirtual list.

Check: With 20-unit rows, a 200-unit viewport, and two extra rows per side, at most 15 row views are present in any frame, even at an unaligned offset. Scroll away from a selected row and back: its state remains, a reused slot does not inherit it, and keyboard focus can cross the visible range. Recheck accessible traversal on the desktop; keep the nonvirtual version as the default until the new version passes.

Read: Qt Quick ListView: item reuse for the separation of model state from recycled views.

6. Shape UTF-8 labels before editing them

Build: Keep FreeType for rasterization; use HarfBuzz to shape runs with a known font, direction, and script into positioned glyphs. Measure and paint from the same shaped output. Start with single-line fixtures using pinned fonts that cover the chosen scripts. Mixed-direction text needs Unicode bidirectional ordering in addition to shaping; don’t advertise general Unicode layout while mixed runs, fallback, and wrapping are still out of scope.

Check: With a font that covers Arabic, inspect a joining word and verify shaped glyphs and their positions rather than drawing one glyph per code point. Compare recorded glyph positions and advances against a pinned fixture; verify a missing glyph follows a documented policy.

Read: HarfBuzz shaping and shape plans and Unicode Bidirectional Algorithm (UAX #9).

7. Add one composition-aware text field

Build: Add a single-line filter, using grapheme boundaries for cursor movement and deletion in the supported editing profile. Keep physical keys and shortcuts separate from text input. Model IME preedit (uncommitted composition), commit, and cancel explicitly. Investigate XIM via Xlib for the X11 host; integrating it with the current XCB event path is its own platform task, not a feature that arrives with HarfBuzz or XKB. Keep mixed-direction editing outside the first release.

Check: Backspace once after e plus a combining acute accent and remove the whole grapheme. Replay preedit → commit and preedit → cancel: only commit changes the filter, once. Repeat with a real IME configured on the target desktop and report the tested session and IME.

Read: Unicode Text Segmentation (UAX #29) and Xlib: Input Methods.

8–10. Polish one layer at a time

Release Build and check Read
8 · HiDPI, still on CPU Separate logical layout and input coordinates from buffer pixels. Inject 1×, 1.5×, and 2× scales: logical bounds and hit IDs stay the same; buffer dimensions and glyph raster sizes change. Define rounding at the pixel boundary. Live per-monitor scale discovery is host-specific; this fixture doesn’t prove it on X11/Xwayland. GDK surface scale as a reference model, not an XCB API.
9 · One transition Add a clock-driven color transition that doesn’t change geometry or input. Test start, midpoint, finish, and no further frames once settled. Add an app-level reduced-motion switch that snaps to the final state; desktop setting discovery is separate. Media Queries: prefers-reduced-motion for the user preference, not a native API.
10 · GPU only if measured Profile the CPU path on a named machine and workload first. If paint or upload is the bottleneck, try one GPU presenter that replays the same clipped rectangles and glyph masks; keep CPU as a reference and fallback. Compare the same fixtures, including resize, and log frame times for both. Don’t change layout and paint semantics to fit the backend. Vulkan Guide: Window System Integration if you choose Vulkan; check your target surface and driver support.

Optional lane: run a real web page

Build a separate spike, not an upgrade to the native renderer. Use one bundled help page in a GTK 4 host with WebKitGTK (webkitgtk-6.0, if packaged for your distribution). WebKitWebView is a GTK widget with its own drawing and input handling, not an XCB drawable or a command you replay into the course’s CPU buffer. Try a separate GTK window first. If you specifically need Chromium, evaluate a pinned CEF build on your Linux target. Its windowless mode delivers pixels to your host and needs explicit resize, input, and focus forwarding. Don’t assume accelerated windowless rendering, a working IME or accessibility bridge, native Wayland support, or Chrome’s full feature set for your chosen build.

Keep the first experiment small: bundled content only, no network or privileged JavaScript bridge. Review navigation and subresource restrictions separately, deny unexpected permissions, downloads, and new windows, and verify sandboxing and who supplies engine security updates before distribution. If a bridge is later necessary, expose only narrowly typed, validated messages to explicitly trusted content—not filesystem or shell access.

Check: Verify the help page loads offline, scrolls, takes keyboard focus, and returns focus to the launcher on close. With networking available in a test environment, confirm an external link, a remote subresource request, and an unexpected pop-up are blocked. Before choosing an engine, test the exact page and required APIs on the target distro, engine build, and display session.

Read: WebKitGTK WebView and policy signals, WebKitGTK security advisories, and CEF General Usage, including off-screen rendering.

The linked upstream docs were checked for availability. These are suggested exercises and acceptance checks, not verified extensions; no specific distro, desktop/IME, WebView build, or GPU configuration was tested for this roadmap.