window

library window

Modules

appkit

The 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.

atspi

AT-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.

browser

The 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. run returns at once, leaving the program running in the browser's event loop. A canvas with the id alloy is 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.

cocoa

Foundation'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.

headless

A 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.

layer

The page's accessibility layer, which browser.alloy's start_layer starts 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's alloy.page.

loading

Functions of the system libraries the platforms load while running.

nsaccessibility

VoiceOver 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.

portal

File 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).

posix

The C library's functions the Linux window uses, apart from the window's own names.

shell

The 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_ranges

What 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.

uia

UI 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.

unicode

UTF-8, the text the program sees, and UTF-16, Windows' and Cocoa's, both ways; positions in one counted in the other.

wayland

The 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 present gives 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_protocol

The Wayland protocols the window speaks, read from their XML while compiling. libwayland marshals each message by the signature and the argument types a wl_interface gives it. The tables here describe those as plain rows, every name and signature in NAMES, since a compile-time result holds no address; Protocol::build lays them out as the C structures when a window opens.

win32

The 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 present gives 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.

window

Windows, 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 run its state and a handler, which the platform's event loop calls with each event until the program closes the window.

xkb

The 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::com

COM on Windows, the package pkg::alloy::com (PLAN.md, F6b; a package of its own since F10, which window and text share): 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 by tests/windows/com_layout.sh.

pkg::alloy::dbus

A 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::wire

D-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::objc

Objective-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 is objc_msgSend read as the method's exact C prototype (F0 question 4), so arguments pass as the method declares them:

std::dispose

Values that must be released by a call, not only freed.

std::equal

Equality: the Equal interface.

std::ffi

Values C holds for Alloy (LANGUAGE_SPEC.md section 6.3): a C library that calls back through an extern (...) -> R function often passes along a void * its caller gave it. c_pointer is that pointer: made from a reference, read back as one by the callback, which names the type it was made from.

std::float_digits

The 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::format

Formatting values as text: the Format interface.

std::fs

The file system: directories, paths and what is at them.

std::hash

Hashing: the Key interface of hash map keys.

std::io

Console and file input/output.

std::iterable

The iteration interfaces driving for loops.

std::json

JSON values (RFC 8259): parsing, writing, reading and building.

std::macros

The built-in compile-time macros (LANGUAGE_SPEC.md section 7.4).

std::map

The hash map.

std::math

Mathematics over floats (LANGUAGE_SPEC.md section 6.1a).

std::number

The numeric constraint interface.

std::option

The optional value: a payload (Some) or its absence (None).

std::process

The running process's environment.

std::result

The outcome of something that may fail: a value (Ok) or the error that took its place (Err).

std::sort

Sorting in place.

std::string

The owned, growable byte string.

std::text

Searching and parsing byte text.

std::time

Time: 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::vector

The growable array.

std::web

The browser's side of a web-wasm32 program, whose event loop is the browser's: the program sets up what the browser calls back, such as animation frames and input events, then lets main return 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.