library window
Modules
appkitThe window on macOS, through AppKit (PLAN.md, F7): the frameworks open while running and every call is an Objective-C message (objc.alloy). AppKit's own loop runs (
[NSApp run], F7 question 2A) and calls the program back through classes made here: AlloyView, the window's content, takes the mouse, the keyboard, input methods (as an NSTextInputClient), the Edit menu's commands, drops and the cursor, and answers VoiceOver (nsaccessibility.alloy); AlloyWindowDelegate the window's closing, resizing, scale and focus; AlloyApplicationDelegate the application's quitting. Each method is a block reaching this module's state through a cell in C's heap, so the classes, made once a process, serve every window run after. Redraws are paced by a CVDisplayLink, whose thread signals a run loop source on the main thread, as a Waker does; frames from the CPU go into the view's layer as a CGImage. The clipboard is the general NSPasteboard and file dialogs are NSOpenPanel and NSSavePanel, run modal. macOS 11 or later.atspiAT-SPI for the Wayland window (PLAN.md, F6c): when the session's accessibility is on (org.a11y.Status), the window joins the accessibility bus, embeds its application object in the registry's desktop and answers screen readers such as Orca from the tree the program sends: org.a11y.atspi.Accessible, Component, Action, Value, Text and EditableText, Table and TableCell, and the properties, on an object a node under /org/a11y/atspi/accessible/. Changes to the tree go out as the Event.Object signals Orca follows; what a screen reader asks comes back to the program as Event::Action.
browserThe window in a browser: a canvas, and the page's events, through the JavaScript beside this file (browser.web.js), which calls the program back for each one.
runreturns at once, leaving the program running in the browser's event loop. A canvas with the idalloyis used when the page has one, sized by its style; otherwise one is added to the page at the configured size. Closing the window stops its events. Input methods compose in a hidden textarea kept at the caret, which has the keyboard while the program asks for text input. Programs using tasks run in a worker, which has no page: their windows do not open yet.cocoaFoundation's values as AppKit passes them, for the macOS window (appkit.alloy) and its accessibility (nsaccessibility.alloy): points, sizes, rectangles and ranges by value, arrays, and the conversions between the view's pixels and the screen's points and between UTF-8 and the UTF-16 NSString counts in.
headlessA window with no platform behind it, for tests: a list of events replayed through the program's handler, and the frames it presents kept for the test to look at.
layerThe page's accessibility layer, which browser.alloy's
start_layerstarts once a program installs screen readers: hidden elements over the canvas, one a node, behind a "Turn on accessibility" button, made by the JavaScript beside this file (layer.web.js). Only the installed layer calls these externs, so only a program installing it bundles that JavaScript, which reaches the canvas, keys and focus through what browser.web.js puts in the glue'salloy.page.loadingFunctions of the system libraries the platforms load while running.
nsaccessibilityVoiceOver for the macOS window (PLAN.md, F7c), through NSAccessibility: the view stands for the tree's root and every other node gets an element, an AlloyAccessibilityElement (a subclass of NSAccessibilityElement made here) holding the node's id, made as VoiceOver reaches it and released once the node is gone. The view's and the elements' methods answer from the tree the program sent; a node of no role is left out, its children standing in for it. The first question about the view asks the program for its tree, and what VoiceOver asks of a node is queued for the window to give the program once the call returns, as on Windows; changes to the tree post NSAccessibility's notifications. A grid's cells go into rows made from their own, elements standing for no node. A node sent with a map of its text answers lines, ranges, their frames and attributed strings from it (text_ranges.alloy), in UTF-16 units.
portalFile dialogs on Linux through the desktop portal (PLAN.md, F6c): org.freedesktop.portal.FileChooser over the session bus, which every desktop answers with its own dialog, inside a Flatpak too. A call gives a request object at once; its Response signal, later, gives the chosen files as URIs. With no session bus or no portal, a dialog is answered at once with no files. The desktop's wish for less motion is read from org.freedesktop.portal.Settings (F11e), its SettingChanged signal telling a change. Reached once a program installs files or screen readers (window.alloy's
install_files,install_access).posixThe C library's functions the Linux window uses, apart from the window's own names.
shellThe Win32 window's file dialogs and drops (PLAN.md, F6b): the shell's IFileOpenDialog and IFileSaveDialog, shown modal to the window, and an IDropTarget registered with OLE, whose calls queue events the window gives the program after them.
text_rangesWhat screen readers ask of a node's text, answered from its TextMap for every platform (decisions/F14.md, F14b): the unit holding an offset, moves by units, the boxes a range covers and the offset at a point. Offsets are bytes of the node's text on grapheme boundaries; each platform counts them its own way (unicode.alloy). Ranges are in the text's order, their boxes in the order they are drawn.
uiaUI Automation for the Win32 window (PLAN.md, F6b): the window answers WM_GETOBJECT with a provider for the root of the tree the program sends, and every node gets a provider as UI Automation asks for it. A provider is one COM object with a table of functions for each interface it answers, at fixed offsets within it: the simple provider, the fragment, the fragment root (the root's only) and the patterns (Invoke for buttons, Toggle for checkboxes, RangeValue for sliders, Value for fields, combo boxes and buttons with a value, ScrollItem for anything, ExpandCollapse for what opens, Selection for list boxes, radio groups, tab lists and calendars, SelectionItem for their options, radios, tabs and days, Grid and Table for calendars, GridItem for their days, Text and Text2 for what has a text map: fields and texts of several lines, whose ranges are COM objects of their own, a node and two byte offsets, answered from the map by text_ranges.alloy). Calls come on the window's thread (ProviderOptions_UseComThreading); what a screen reader asks goes to the program as Event::Action, and changes to the tree raise UI Automation's events while a client listens.
unicodeUTF-8, the text the program sees, and UTF-16, Windows' and Cocoa's, both ways; positions in one counted in the other.
waylandThe window on Linux, through Wayland: libwayland-client, loaded while running, speaks the protocols wayland_protocol.alloy reads from their XML, one dispatcher receiving every event. The window is an xdg-shell toplevel, decorated by the compositor where it offers to (xdg-decoration; GNOME does not), at the compositor's fractional scale where it gives one (fractional-scale and viewporter), else its integer one. Frames
presentgives go through shared memory, a GPU surface drawing into the wl_surface itself. Input methods speak through text-input-unstable-v3, which GNOME and KDE implement.wayland_protocolThe Wayland protocols the window speaks, read from their XML while compiling. libwayland marshals each message by the signature and the argument types a
wl_interfacegives it. The tables here describe those as plain rows, every name and signature inNAMES, since a compile-time result holds no address;Protocol::buildlays them out as the C structures when a window opens.win32The window on Windows, through Win32, whose system libraries every Windows program can call: a window procedure receives every message. The process is aware of each monitor's DPI (the scale is the DPI over 96), frames
presentgives go through GDI and a GPU surface's through its swapchain, and DWM paces redraws one after another to the display. Input methods speak through IMM32, the program drawing their compositions. Screen readers read the program's tree through UI Automation (uia.alloy), and the shell's file dialogs and OLE's drops come through COM (shell.alloy), the window's thread a single-threaded apartment. Needs Windows 10 1703 or later.windowWindows, their events and input on every platform (PLAN.md, stage F1): Wayland on Linux, Win32 on Windows, AppKit on macOS (F7), a canvas in the browser, and a headless window for tests. A program gives
runits state and a handler, which the platform's event loop calls with each event until the program closes the window.xkbThe keyboard on Wayland: the compositor sends its keymap in xkbcommon's text format, which libxkbcommon turns into keys, text and modifiers for each key code (loaded while running, like libwayland-client).
Dependencies
pkg::alloy::comCOM on Windows, the package
pkg::alloy::com(PLAN.md, F6b; a package of its own since F10, whichwindowandtextshare): interface ids, calls through another object's table of functions, and the strings, arrays and variants UI Automation, the file dialogs, drops and DirectWrite pass, with UTF-16 text both ways. The tables' slots each user reads are checked against MinGW's headers bytests/windows/com_layout.sh.pkg::alloy::dbusA D-Bus client (PLAN.md, F6c): a connection to a bus over a Unix socket, authenticated as the process's user (SASL EXTERNAL), which sends method calls, replies, errors and signals and receives them, for the accessibility bus and the desktop portal and any program using the session or system bus. Calls can wait for their reply; everything else arrives through
receive, which never blocks, the connection's socket polled beside a program's own (fd).pkg::alloy::dbus::wireD-Bus's wire format, little-endian: values written and read by their signatures, each aligned to its size from the message's start, and the messages around them (a header of fixed fields and a field array, then the body).
pkg::alloy::objcObjective-C from Alloy (PLAN.md, F7), the package
pkg::alloy::objc: the runtime's C functions, loaded while running, for AppKit and Metal on Apple systems. Every message isobjc_msgSendread as the method's exact C prototype (F0 question 4), so arguments pass as the method declares them:std::disposeValues that must be released by a call, not only freed.
std::equalEquality: the Equal interface.
std::ffiValues C holds for Alloy (LANGUAGE_SPEC.md section 6.3): a C library that calls back through an
extern (...) -> Rfunction often passes along avoid *its caller gave it.c_pointeris that pointer: made from a reference, read back as one by the callback, which names the type it was made from.std::float_digitsThe shortest decimal digits of a float that read back to the same value, by Ryu (Ulf Adams, "Ryu: fast float-to-string conversion", PLDI 2018), which std::format writes floats with (LANGUAGE_SPEC.md section 6.5). Integer arithmetic only, so compile-time code formats floats too.
std::formatFormatting values as text: the Format interface.
std::fsThe file system: directories, paths and what is at them.
std::hashHashing: the Key interface of hash map keys.
std::ioConsole and file input/output.
std::iterableThe iteration interfaces driving
forloops.std::jsonJSON values (RFC 8259): parsing, writing, reading and building.
std::macrosThe built-in compile-time macros (LANGUAGE_SPEC.md section 7.4).
std::mapThe hash map.
std::mathMathematics over floats (LANGUAGE_SPEC.md section 6.1a).
std::numberThe numeric constraint interface.
std::optionThe optional value: a payload (
Some) or its absence (None).std::processThe running process's environment.
std::resultThe outcome of something that may fail: a value (
Ok) or the error that took its place (Err).std::sortSorting in place.
std::stringThe owned, growable byte string.
std::textSearching and parsing byte text.
std::timeTime: a monotonic clock for measuring, the wall clock, sleeping, and the calendar: days of the proleptic Gregorian calendar, times of day and the system's offset from UTC; time zones by name from the platform's database, dates and times on a zone's clocks, and ISO 8601, RFC 3339 and HTTP dates (F12e, notes at the end).
std::vectorThe growable array.
std::webThe browser's side of a
web-wasm32program, whose event loop is the browser's: the program sets up what the browser calls back, such as animation frames and input events, then letsmainreturn while it keeps running. Externs a module declares come from the JavaScript beside it,<module>.web.js(section 6.3), as this module's do.