Skip to content

UXAppKitDriver

UXAppKitDriver is the macOS realization of UXViewDriver. The neutral toolkit (UXView, UXWindow, the widgets) runs on it unchanged.

#use <UXKit> // or #import "UXAppKitDriver.xc"

Like every driver, it is selected at boot and reached through gDriver. Application code names it in one place, the platform line that chooses a backend, and nowhere else.

A program that calls UXAppKitDriver methods directly only runs on macOS.

A UXWindow is a real NSWindow, but a UXView is generally not a real NSView. The driver keeps its own shadow tree, a flat array of nodes with parent and sibling links, and walks it to paint and to hit-test.

Painting goes through one flipped UXDrawView per window, whose drawRect: is the paint entry point. A window with forty views has one native view and forty drawn ones.

UXWin32Driver and UXGtkDriver share this shape. The walk is backend-neutral, and only the painting vocabulary differs.

Some widgets are realized, as native overlays that read directly from the neutral model:

neutralnative
UXTableViewNSTableView
UXOutlineViewNSOutlineView
UXSliderNSSlider
UXPopUpButtonNSPopUpButton
UXStepperNSStepper
UXSegmentedControlNSSegmentedControl
UXProgressBarNSProgressIndicator
UXToolbarNSToolbar (window chrome, not a subview)

The framework’s rule is to use the native UI where the user can tell the difference. A drawn approximation of an NSTableView is never as good as an NSTableView, and a slider that does not feel like the platform’s slider is worse than one that does.

The overlay reads the neutral object and does not copy from it, so the model stays the single source of truth and there is no synchronisation step.

Everything AppKit-specific goes through libUXAppKit.m. At that boundary, no NSRect crosses into xtc. The shim’s exported signatures use only primitives:

i32 ux_ak_window_create(i32 x, i32 y, i32 w, i32 h);
void ux_ak_window_open(i32 handle);
i32 ux_ak_open_panel(u8* prompt, u8* startDir, u8* out, i32 outCap);

Windows are i32 handles, not pointers. Strings are u8* with an explicit capacity, and structs do not cross the boundary. Both sides can then agree on the ABI without knowing each other’s layout rules.

Live: events, menus, alerts, scrolling, tables and outlines, and the native open, colour and font panels.

Not implemented:

  • windowSetSubtitle / Info / Icon / Modified. NSWindow has subtitle and documentEdited, so these are unfinished, not unavailable.
  • the toolkit’s own file-panel operations (listDir, fileDelete, …). These are intentionally unused, because macOS presents NSOpenPanel.

When reading the driver, treat an unimplemented method as a gap and an intentionally absent one as a decision.

Under [NSApp run], AppKit owns the run loop, and the toolkit’s dispatch is driven from it (see UXApplication).

This is the usual arrangement for a hosted toolkit. For the same reason, an @autoreleasepool around window ordering or activation causes trouble: the scope ends inside AppKit’s own bookkeeping.