RediWM is a Wayland compositor written in Zig (OpenGL ES) that includes everything in one process
Shared widget internals
The rules every caller follows (callback owners, one look per control, app
text and colours, secrets) are in the root AGENTS.md ("Shared UI").
Hover/selection outlines use
widgets/highlight.zigin Cairo item and sidebar rows and Settings navigation.app_highlight_bevelopts into straight cut corners; zero preserves each caller's rounded radius. Keep sidebar markers clipped to that outline and retained repaint damage unchanged. Any widget rect can cut its corners withRectStyle.bevel(fillRecthands it tohighlight.fillBeveled; no relief orreplace). The power menu uses it throughpower_menu_bevel, rounding its glass to stay inside the cut. LikefillRectPlain, a beveled fill shades only the pixels near an edge: each row's interior is one run (stored, blended, or skipped for an outline).The scrollbar (
widgets/scrollbar.zig, Files' look): a thumb (track-less unless painted track tokens orscrollbar_track_reliefenable one; flat atscrollbar_glow = 0) centred in agutter(scrollbar_width)strip, thin at rest, widening and tinting to the accent on hover/drag, holding a faint tint after a scroll.Geometry.computegives the thumb for any axis and unit (pixels, or items for a strip that scrolls by item),pressthe grab-or-page decision,Dragthe pointer-to-offset map,look+paint(Renderer) /cairo.drawScrollbar(Cairo) the pixels, andAppearance.stepthe feedback. It is edge-triggered on what is drawn: the app's loop sleeps untildeadlineand runs frames only whileactive(barTimeoutin PDF/Editor,animationTimeoutin Images,pollTimeoutin Files). Paint-only popups pass.{}for the rest look. The gutter belongs to the bar: layouts keep content out of it and a press in it never reaches content. Never changeAppearance.widthper call site: it is every bar's width. Hover fades in a pale reflection ofborder_glowalong the thumb's edge; dragging and the scroll hold brighten it.Appearance.illuminationshares the existing frame/deadline scheduling (no idle animation). Cairo uses the shared raster for the lit thumb, preserving its fractional device position.scrollbar_trackandscrollbar_track_stripeoptionally paint a stationary hatched channel (both transparent by default).scrollbar.hasTrackalso controls Cairo's layer bounds: include the whole channel even without relief. Stripe period, width and slope also come from the theme throughLook; period/width zero hides the stripes, and slope zero draws transverse bands. App clients paint the channel on every scroll frame: keep its loop free of soft-float calls (@mod,@floor,@roundon a baseline x86_64 target).Text fields with child accessories reserve text/caret room with
field.trailing = .accessory. Place a shared button in the field's children (Settings search uses a ghost clear button), so normal pointer and keyboard dispatch handles it inside the field frame.Scroll containers (
.scroll_container) give widget trees all of the above: hosts callscroll_container.stepBarsbesidestepGlidesand carryScrollState.baracross rebuilds. It scrolls along itsdirection, which defaults to.row(sideways, bar along the bottom edge), so set it explicitly. Rebuilt trees carry the offset over themselves (the wallpaper strip copies it from its old widget). Appearance's wallpaper strip owns awallpaper_strip.Strip(decode worker + eventfd) that outlives rebuilds and restarts only when the image list changes; thumbnail slices stay valid until then.Sliders reuse the scrollbar's feedback (
SliderData.feelis ascrollbar.Appearance): hover and drag tint and thicken the track, a change holds the faint tint.stepBarssteps sliders too (slider.stepFeedback);Dispatcher.setHovered/pointerLeavekeephoveredin step. A value readout isslider.valuePill(a.textwithpill), found from its slider byfindPill(first pill under the slider's parent) and lit by drag only. Saving a theme slider rebuilds Settings the moment the button is released, sopanel.rebuildTreecarries named sliders' state across on the same page (slider.capture/restore+input.adoptHover); an unnamed slider starts fresh.Switches slide (
widgets/toggle.zig):ToggleData.knobeases the knob (and the track's off/on colour) overslide_ms, andpainttakes the position (Options.position; null rests aton, which hand-laid panels such as the network popup still use).scroll_container.stepBarscallstoggle.step, which retargets whenonchanged, repaints only on a changed position and snaps when animations are off or reduced; a switch no frame has seen starts at rest. A page rebuild that follows a click happens before the first frame moves the knob, soControlCenter.rebuildTreecarries named switches' knobs across withtoggle.capture/restore(by name hash: arena names don't outlive the rebuild). A host that builds.togglewidgets must callstepBarsor its switches never leave their first position.Dropdowns survive unrelated page updates. On a rebuild of the same page, use
select.capture/restoreand restore input focus to the returned widget. The saved state owns its bounded name copy: the old tree's arena can be freed. Changed options, disabled choices, owner/id, or backend selection invalidate the saved menu; restoration never replaces the new backend value. Settings does this beside its slider and switch capture, so a live Services update cannot discard an in-progress Notify choice.The battery badge (
widgets/battery.zig: frame, glyph, percentage, charging bolt) is the taskbar's artwork.sampleis the pixel math (per device pixel, badge-local units); the taskbar's per-pixel raster calls it andpaintdraws it into anyRenderer, so the two cannot drift. The caller owns the data (hide it when there is no battery) and the connection shimmer's clock (Spec.shimmer).Relief on hand-shaded controls. A control drawn through
fillRectopts in withRectStyle.reliefand a theme key. One that lights its own pixels (the shaded toggle and slider) paints first, then callsRenderer.paintShapeReliefwithReliefLimits: a groove passes.outside(the knob), a knob passes.within(its track or the control's box), so shadows never cross the thumb or leave the damage bounds.Renderer.reliefActivetells it whether to drop the hand-made rim or cast shadow the relief replaces; flat keys must leave its pixels byte-identical.Pointer effects in Cairo app clients repaint only what they change.
cairo.drawProximityGlowreturns before allocating a layer when the glow is off, unlit, or outside the context's clip, and sizes its layer to the visible part; paint-only components useLayer.beginVisible. Images and PDF record glow and hover changes as rects inpointer_damage(repaint.Region) and repaint them clipped, paced by the frame callback, with each shm buffer'sstaleregion catching up what it missed; never answer a glow change withdirty(a full, unpaced repaint at pointer rate). Hand-drawn content must stay inside the rects a damage helper adds for it.The titlebar tab strip (
widgets/title_tabs.zig): model (Tab,Strip),geometry,hit, the damagehash/layoutHashandDrag(press, motion, release and the preview rectangle for a reorder). No painting: the compositor paints it inchrome_tabs.zig. Tab ids are non-zero (0 means none inStrip.hoverandDrag.id).Dragreorders nothing itself;releasereturns the final index for the owner to apply. Plan:docs/plans/titlebar-tabs.md.