c8ui toolkit #
Metro UI toolkit: libc8ui-core (widgets, icon themes, no window system) and libc8ui (Wayland client host); and c8-base (base/, a static library and headers with pkg-config c8-base, GLib and GIO only: what the apps' cores, tile providers, the shell and PC settings' daemons share under the UI).
Depends on: cairo, pango, glib, xkbcommon, librsvg (svg feature, on by default).
Every app is built on this: read it before writing or changing app UI.
Kept apart for their size; read the one the work is in:
-
DRAWING.md(beside this file): damage, drawing fast (kept drawings, pictures), what a draw fn may and must do. Read it before writing a custom widget or any draw fn, in the toolkit or an app. -
WIDGETS.md(beside this file): what there is to build with: the bigger widgets, file pickers and thumbnails, charms, clipboard, drag and drop, menus, popups, hub. Read it before building app UI. -
base/CLAUDE.md: c8-base (json.h,http.h,tiles.h…). -
Core is host-agnostic: a host implements
struct c8ui_host_impl(queue_redraw, request_frame, timers, cursor, shortcut inhibit, clipboard).c8ui-waylandis one host (GLib main loop, xdg-shell, fractional scale, cursor-shape, clipboard).c8ui_window_new_bare+c8ui_window_configurehost a surface whose role the caller gives (how c8-shell makes its shell surfaces);c8ui_window_set_background(alpha < 1 = see-through). A window's two shm buffers (16 MB full screen) are let go when it's unmapped,REST_S(5 s) after it last drew (rest, made again for the next frame, a couple of ms), and whilec8ui_window_suspended (mapped but not shown, as Start behind an app: nothing is drawn until it's lifted); one the compositor still holds goes on its release (buffer.drop). -
For an app with a surface of its own under its window (c8-video's video):
c8ui_window_set_fullscreen/_is_fullscreen/_on_fullscreen(the toplevel's configured state),c8ui_window_scale/_on_scale, andC8UI_CURSOR_NONEwithc8ui_widget_set_cursor(applied at once when the pointer is over the widget;w->cursoralone waits for it to move). -
Narrow windows (snapped to a quarter, ~474 px):
c8ui_root_is_narrow(belowC8UI_NARROW_WIDTH, 600). An app builds a page once and the widgets reflow by themselves; building wide and narrow apart and rebuilding on the flip is a design mistake (the user's rule, 2026-12-01: Cirrus pages stayed wide in a snapped window because one builder never ran again). How: the impl'snarrowhook, called children first when the root crosses the line and when a widget is put in a tree whose root has a size (tell_narrowin core.c; every hook hears its first state,narrow_told), andw->narrow(c8ui_widget_narrow) kept current on every rooted widget, hook or not. On it:c8ui_box_set_narrow_padding/_narrow_spacing/_narrow_orientation(a row that goes down),c8ui_label_set_narrow_style,c8ui_scroll_set_narrow_directions,c8ui_widget_set_narrow_hidden(narrow_hides, applied intell_narrow), a horizontal split stacks itself, rich columns become one column of the width given, a scroll inside one going down gives way (measures as tall as its child, so a sideways list sits in a column),c8ui_pagesgoes one at a time (narrow, or under its pane + 460, so 760 for a 300 pane, 800 for PC settings' 340; the open page kept), the hub turns into a pivot of its named sections or, withc8ui_hub_set_narrow_column, one column going down (News, Weather; back wide it pans to the section that was showing), Miller columns show the last one. An app's own widget does the same with the hook (Cirrus's section heads andmover).c8ui_root_on_resize(every size change, before the next layout) is for sizes, such as a list's cell width, never for building again; showing and hiding panes there (Files' places, Notes) is fine.c8ui_pages_set_narrowandc8ui_miller_set_narroware gone; every app, c8-lua's bundled ones, the gallery and the template build once (2026-12-01; the shell's share picker only sizes its band inresized, its margins centring it, which is what the hook is for). The impl and the widget struct grew for this: rebuild everything. Apps narrow go to one column like a phone app: one pane at a time, lists before details, a back button between. Afixed_widthgives way when the room given is smaller; the app bar wraps its commands into rows (global ones on top) when one row won't hold them.c8ui_nav_set_menumakes a nav a narrow page list (arrows move a cursor, Enter/click opens, the selected item too).c8ui_pages(pages.c) is PC settings' layout once, for any app: a dark page list beside the page, or one at a time with a back button (Escape,c8ui_pages_back), the title (SUBHEADER narrow) and paddings, one page built for both widths; the app's build fn fills a page's body.c8ui_pages_set_subputs a page over the chosen one (Tailscale's device page, Tile maker's editor;c8ui_pages_on_backhears it go). Back to the list destroys the page, so a page stops what it does in itson_destroy. PC settings, Tailscale and Tile maker use it. Tested headless (nested c8 at 1600x900, Super+Left/Right to ~533 and Super+Down back, 2026-12-01): those three (page kept on snap, back to the list, unsnapped beside the list), Cirrus's hub, profile, feed and thread pages, News, Weather, Files' split, Photos, Video, PC info, shortcuts and Night light, Calculator, Notes, both galleries. Untested: touch, a window resized by dragging across the line, the Lua bindings over it. -
c8ui_window_on_close_request: the compositor's close (Alt+F4, the bar's button) asks first, and false keeps the window, for asking about unsaved work (c8-lua'scan_close). Without one it closes as before.win:close/c8ui_window_destroynever ask. -
Scroll events carry
precise(touchpad) andmods;C8UI_EVENT_SCROLL_STOPis the fingers lifting (wl_pointer.axis_stop). -
Touch (wl_touch):
C8UI_EVENT_TOUCH_DOWN/MOTION/UP/CANCELwithtouch_idandtime. The widget that returns true for DOWN owns that finger; a finger nobody takes acts as the mouse (press, motion, release, then no hover), so mouse-only widgets work by touch. -
Touchpad swipes of 3+ fingers (pointer-gestures):
C8UI_EVENT_SWIPE_BEGIN/UPDATE/ENDwithfingers; the widget under the pointer that takes BEGIN gets the rest (the compositor sends two fingers on the touchscreen as a three-finger one).c8ui_tab_swipeis the one rule for a sideways one stepping tabs (once per swipe,C8UI_TAB_SWIPEpx): Start's All apps tabs, pivots and hub sections all use it. Pinches the same way:C8UI_EVENT_PINCH_BEGIN/UPDATE/END,scaleagainst the start. Two fingers on the touchscreen are one too (tpinch_*in core.c): a second finger landing while one is down offers PINCH_BEGIN at their midpoint; a taker gets both as PINCH_UPDATEs (dx/dythe midpoint's move), the first finger's touch is cancelled, and the finger left when the other lifts is ignored until it lifts too. Nobody taking it: plain touches. -
Icons:
c8ui_icon_*(freedesktop theme lookup, SVG via librsvg, a background loader the host polls by fd; c8ui-wayland hooks it up). -
Retained widget tree with measure/layout/draw/event/tick vtables, overlays for popups/dialogs, focus chain, Metro entrance animation (
c8ui_widget_enterslides in from the right;c8ui_widget_enter_uprises from below, for what comes up over a bar: the shell's cards over XR's charms bar;c8ui_widget_leave_downis the way out, fading and dropping overC8UI_LEAVE_MS, then not drawn until the caller takes it away).leaving,tiltsandtilt(the press tilt, WIDGETS.md) are fields ofc8ui_widget: rebuild everything with c8ui after they change. -
Widgets destroyed during event dispatch go to a graveyard and are freed after dispatch. Callbacks must not keep pointers to widgets past
on_destroy; pages clear their static pointers in the page box'son_destroy, only if the pointer is still that widget (if (x == w)): a rebuild sets the new one before the old one is destroyed.c8ui_widget_track(w, &slot)does exactly that for one pointer (sets it, clears it on destroy if it still points at w; the slot must outlive the widget): use it instead of a handler that only clears pointers. -
Apps:
c8ui_app_main(&info, argc, argv)(src/app.c) makes one copy run: it owns the app id on the session bus (DO_NOT_QUEUE) and servesorg.freedesktop.Application; a later launch resolves its arguments to URIs (its own cwd; an argument that has a scheme other thanfile:goes as it is, since GIO's GFile for an unknown scheme readsat://did:plc:xas host:port and made itat://did:0) and hands them over with Open/Activate, carrying itsXDG_ACTIVATION_TOKEN, then exits.info.openruns for every launch;c8ui_window_presentuses that token (or one from input on another of our windows; deferred until mapped). The charms then serve on that connection instead of queueing.c8ui_window_open_uriopens in the default app with a token of ours (a GAppLaunchContext subclass). The compositor gives everythingc8_launchruns a token (c8_launch_token, accepted byrequest_activate), so Start launches of a running app bring it forward. Wake-ups (info.wake,info.command,c8ui_app_wake_at/cancel/done, the shell'sorg.cont8nuum.Wake1): argv's--c8-wake TAG DUE(taken out before the URIs) is handed to a running copy as ActivateActionc8-wake([s tag, x due]); without one the app starts, runsstartupthenwakeinstead ofopen, held (c8ui_app_hold) untilc8ui_app_wake_doneorC8UI_WAKE_SECONDS.c8ui_app_infogrew: everything that callsc8ui_app_mainmust be rebuilt with it (the library readscommand).toolkit/c8ui/template/is a standalone app to copy (meson,.desktopwithMimeType=and update-desktop-database, icon); not built bybuild.sh. -
Touch panning:
struct c8ui_drag+c8ui_drag_touch(private, core.c) is shared by scroll, hub and pivot: a drag along the widget's axis pans, a tap clicks, a hold right-clicks, and a drag the other way is offered to the widgets around it (as a fresh TOUCH_DOWN) before it becomes the mouse (sliders, text selection). -
Scrolling something into view goes through
c8ui_widget_reveal, which calls therevealhook of every ancestor that has one (scroll, hub); don't assume aclipsparent is ac8ui_scroll. Adding fields toc8ui_widget_implchanges its size: rebuild everything that defines widgets (c8-shell) with c8ui, whichbuild.shdoes. -
Text: Selawik is unhinted (no fpgm/prep), so FreeType autohints it;
c8ui_text_layoutuses grey AA + slight hinting, andc8ui_app_new(and c8's main, exported to the session) setsFREETYPE_PROPERTIES= autofitter:no-stem-darkening=0first thing, or Light text is faint and ragged. Full hinting looked crisper but broke the spacing. -
Theme (accent, background, font) comes from config.ini (
[appearance],[general] font; an old start.ini[appearance]is the fallback) and is watched with GFileMonitor; c8-settings also takes it from the settings snapshot.