gpui-cc Course handbook
REFERENCE / FIELD NOTES

Beginner learning audit

What each stage teaches before asking you to build it.

The learner knows basic programming and has some C/C++ experience. They have never worked with XCB or a UI framework’s internals. Each row below pairs a missing mental model with something small to run and change before the real challenge. A worked example teaches the mechanism without implementing the stage’s framework contract. The framework plan owns implementation dependencies and acceptance tests; this audit owns teaching dependencies.

Pilot: desktop foundations

Stage What the previous lesson took for granted Worked example before the challenge What the learner builds independently
C0 · Build A source file, build recipe, build directory, and runnable binary are different things. starter/cmake-demo: configure a tiny C++ target, run it with two different inputs, and compare output and exit status. Create the course’s own repo, target, output path, and greeting.
N1 · Connect A display address is not a window; a non-null handle is not a successful connection; shells distinguish stderr and exit status. inspect-display.cpp: explicitly test a named display and report the server’s selected screen number. Compare a usable address and invalid address. Wire XCB into the real target and preserve a --probe-display mode that uses the default display and meets the checker contract.
N2 · Map a window Screen, root, window ID, checked request, and map state were named but never demonstrated. Neither title properties nor event waits were shown. map-state.cpp: ask the server whether a tiny, short-lived untitled test window changes from unmapped to viewable. Separately read annotated title and event-wait fragments. Build and keep alive a normal, titled top-level app window with the required dimensions.
N3 · Close Atoms, the protocols property, the synthetic-event bit, and event ownership were hidden prerequisites. inspect-message.cpp: decode two in-memory XCB event headers without either a display server or a live close loop. Compare changing an operation with changing the event kind. Register the actual window-manager protocol, match the whole close message, and distinguish close from lost connection.

Chapters 2–5: teaching map

Stage Teach first Runnable worked example to author
R1 · Present A native window is a destination; CPU pixels are storage we own. Server depth, storage bytes, and RGB channel order are distinct. Read three known RGB values from a small owned buffer and inspect their bytes; demonstrate that packing unequal red and blue is observable. Show the server format query before any native upload.
R2 · Resize A dimensions change invalidates views into the old storage. Expose is a request to show content again, not necessarily permission to change the model. Replay two sizes and two expose requests using a small buffer owner and a fake uploader; print allocation count and upload sizes.
R3 · Clip a rectangle Row-major memory, stride versus width, half-open edges, and clipping before access. Change one pixel in a padded 3 × 2 buffer, print the rows including padding, then inspect an intersecting pair of 1D intervals. Combine those in the exercise, not in the example.
R4 · Order paints A recorded paint command is data, not a pixel write; order and inherited clip matter. Replay two writes to one color cell, reverse them, and see which wins. Trace a parent clip and one child clip before handling nested scenes.
L1 · Measure and place Desired size, permitted size, and final origin are separate values. Clamp the requested length of a single strip with two available lengths; print local width and a separate placement offset.
L2 · Compose layout Local coordinates become window coordinates once; padding/gap use space and clipping does not redistribute it. A three-node outline prints compounded origins; observe the double-offset bug by changing the child origin independently.
I1 · Hit a target Hit testing reuses resolved geometry, not source coordinates; visual order determines overlap precedence. Query one resolved rectangle at its left edge and its excluded right edge; vary the effective clip. Do not provide a scene hit-test implementation.
I2 · Route pointer actions OS activation is not element focus. A down/up sequence is distinct from a click and can be cancelled. Replay a press, leave/cancel, and release through a toy state machine, printing transitions; show the raw XCB event lifetime separately.
S1 · Preserve app state Rendering a fresh element description must not reset the application’s data. Rebuild disposable rows from a persistent star-rating value and show the same value appearing in successive descriptions. Use geometry/color to observe output; text has not been taught yet.
S2 · Coalesce redraw Updating, rebuilding, and presenting are separate; a dirty flag keeps work pending without recursively drawing. Feed a fake clock-free batch of invalidations into a counter of rebuilds and presents and compare two updates in one turn with two distinct turns.
I3 · Move focus Stable identity is not a node address; tab order is defined by the current eligible controls. Reorder and replace a list of named items, then compare recovering one selection by value versus position.
I4 · Activate by key X11 keycodes, key symbols, modifiers, and semantic actions are separate. Print one keycode, its resolved symbol, and shifted symbol on an isolated test window. Use keymap probes before asking for a full fallback or repeat handling.
T1 · Measure text A character is not a bitmap; an advance moves the pen and a space can do so without ink. Load one face, compare the blank space glyph’s advance and visible bounds with a printed letter, and repeat at another size.
T2 · Paint text Glyph-slot data is borrowed until the next load; baseline, bearings, and coverage are different quantities. Blend three synthetic coverage values over one background and print results. Follow with a one-glyph measurement, not a complete text painter.
A1 · Integrate an app The application declares elements and handles actions; the framework owns the platform, layout, and pixels. A miniature, non-counter consumer shows the calls through the public boundary. Trace the first frame and one action before asking for the full counter.
A2 · Reuse the API Linking a second consumer is evidence only if neither the framework nor the first app must change. Link two tiny programs to one small library target with separate models, then apply that structure to the second UI app.

Dependency traps to avoid

  • Don’t write a rectangle before demonstrating a real pixel destination and the smallest observable frame.
  • Don’t demand a text label to prove state changes while text rendering is still untaught.
  • Introduce native activation and cancellation before requiring pointer logic to use them. Introduce keyboard mapping before asking for Tab/Return, not after a raw-keycode solution has been written.
  • The course author verifies the worked example separately from the stage checker. An example that compiles but cannot be understood or run from the learner’s terminal is still a teaching failure.