module pkg::alloy::windowsource
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.
import pkg::alloy::window;
fn on_event(clicks: &var u32, window: &var Window, event: &Event) {
match (event) {
::Button |&b| {
if (b.pressed) {
clicks += 1;
}
}
::CloseRequested {
window.close();
}
else {}
}
}
fn main() -> i32 {
return run(&WindowConfig::titled(&"Clicks"), 0 to u32, on_event);
}
What a program uses of the platform beyond the window it installs:
screen readers (window.install_access(), which pkg::alloy::ui_access
calls) and file dialogs and drops (window.install_files(), which
pkg::alloy::ui_app calls); a program installing neither links none of
their code.
Sizes and positions are in physical pixels, the display's own; the
scale says how many make one logical pixel (2 on a typical high-density
display), so a program draws scale times larger to look the same
everywhere.
## How it was built
Notes kept from each stage as it was finished, the sizes and numbers of their day; what changed since is in REVIEW.md and the history.
**F1 as built** (2026-10-12):
run(config, state, handler)erases the state and handler into one closure the platform's loop calls;Windowcarries what the handler asks (title, redraw, close, a presented frame), applied once it returns. Sizes and positions are physical pixels with the scale apart.- Headless:
run_headlessreplays a list of events, keeping each frame presented;alloyc test window/tests.alloy. - Wayland: libwayland-client and xkbcommon loaded through
Library; the protocols' XML (window/protocols/) read at compile time into tables identical to wayland-scanner's; one dispatcher for every event; frames inwl_shmbuffers paced by frame callbacks; xdg-decoration, fractional-scale, viewporter and cursor-shape used where offered (GNOME offers no server-side decorations: client-side ones come with the UI). Key repeat from the compositor's rate; no compose or IME yet (F4). - Win32: a window procedure reaches its state only through a call
(
GetWindowLongPtrW), so a loaded library's functions cannot reach it; user32, gdi32 and dwmapi are therefore linked into Windows programs, imported only by programs calling them. Per-monitor DPI, GDI frames,DwmFlushpacing. Runs over SSH up to drawing, which a session without a desktop never asks for. - Web:
browser.alloywithbrowser.web.js, a canvas (#alloyor a new one) and the page's events,requestAnimationFramepacing; state kept for callbacks throughstd::ffi::c_pointer::keep. A program using tasks runs in a worker, with no page: its window cannot open yet. std::ffigainedview,view_var,c_text,c_pointer::of,c_pointer::keepandtake(spec section 6.3).scripts/test.shruns the tests, builds the samples and test programs for four targets, and runstests/frames.alloyin a page node fakes and under a headless weston.
**F6a as built** (2026-10-13):
window: the tree's types (Role,Semanticswith defaults,AccessNodewith bounds in window pixels,TreeUpdate,Action,ActionRequest, andAccessTree, which applies updates);window.update_access(update),Event::AccessRequestedwhen a screen reader starts andEvent::Actionfor what it asks.Semanticsis flat (valuea string,checked: Option<bool>,range,selectionas anchor and caret,disabled,focusable,multiline) rather than the design's nested states.- Headless:
Replay.access, the tree the program left. Web: a hidden "Turn on accessibility" button is what a screen reader finds first; pressing it givesAccessRequestedand makes a layer ofdivs over the canvas, one a node, with ARIA roles, labels, states and values, placed at their bounds; a click on one isAction::Click, focusing oneAction::Focus, and keys pressed in the layer go to the window. The tree goes to the page as JSON (layer.alloy'saccess_json). Windows and Wayland drop the updates until F6b and F6c. - The clipboard, text only:
window.set_clipboard(text)andwindow.request_clipboard(), answered byEvent::Clipboard(text), empty when it holds none. Wayland:wl_data_device_managerv3, a data source offeringtext/plain;charset=utf-8,UTF8_STRINGandtext/plain, set as the selection with the serial of the last input; a paste reads the selection's offer through a pipe the loop polls beside the socket and the waker, or answers at once while the window holds the selection. Windows:CF_UNICODETEXTthroughGlobalAlloc. The web:navigator.clipboard. Headless: kept inReplay.clipboard. ui:Widget::semantics(default: no role, the element's children given to its nearest described ancestor);Texta label,Button,Checkbox,Slider(itsaccessibletext the label),TextField(its text, selection and multiline; labelled byaccessibleor its placeholder),Image(described only withaccessibletext),Scrollandui.list. Every built-in option struct with a label gainedaccessible. Node ids are an element's generation and index; the window is node1 << 63.- The walk, sent once a screen reader asks, and the actions: in pkg::alloy::ui_access's notes since R6f.
TextFieldtakes Ctrl+C, Ctrl+X and Ctrl+V:ui.set_clipboard(text)andui.request_paste(), the text coming back to the element that asked asInput::Paste.- Tests:
window/tests.alloy(the clipboard and the tree in replays),ui/tests.alloy(the tree and its updates, actions, copy, cut and paste, an app answering a screen reader);tests/accessunder weston (no seat: an empty clipboard) and in node's page, whose fake DOM (tests/web/dom.mjs) gained elements, a clipboard and, withALLOY_SCREEN_READER=1, a screen reader printing the layer and clicking and focusing in it. Samplenotes.alloy. textdraws a face's empty .notdef (Inter's) as a hollow box, so a character the bundled font lacks, such as Japanese typed through an input method, shows until F10's fallback draws it.- Sizes: the tree, its comparisons and the clipboard add about 50 KB to
the counter (1.47 MB native, 1.17 MB on the web, whose budget went
from 1.15 to 1.2 MB) and 12 to 15 KB to a program using
windowalone; the page's JSON carries numbers as their bits so no program takes float formatting for it.
**F6b as built** (2026-10-13), with the files and drops every platform shares:
window:window.open_files(dialog),save_file(dialog)andsave_bytes(dialog, bytes)(the web's download), each giving a request id answered byEvent::FilesChosen(Chosen { request, files }), no files when cancelled;ChosenFile { name, path, bytes }as question 5 decided. Drops: `Event::DragEntered(Dragged { position, files, text }),DragMoved(Point),DragLeft,Dropped(Drop { position, files, text }). Headless:Replay.dialogs` answers dialogs from the script. The web: an<input type=file>read into bytes,showSaveFilePickerwhere the browser has it and a download otherwise, and the canvas's drag events.ui:ui.open_files(dialog, (ui, files) => ...)andui.save_file(...), handlers kept by request id;on_droponColumn,RowandStack, the container under the pointer drawn withlook.drop_targetwhile something is dragged over it.- COM (
window/com.alloy): interfaces as structs of C function types read from an object's table by slot (method(obj, i)), GUIDs parsed at compile time (guid("...")), objects Alloy makes beingc_pointer::keep'd memory starting with their tables, counted byAddRef/Release,QueryInterfaceanswering by GUID. The slots are checked against MinGW's headers bytests/windows/com_layout.sh. The window initializes OLE (single-threaded) on its thread. - UI Automation (
window/uia.alloy):WM_GETOBJECTwithUiaRootObjectIdreturns the window's root provider throughUiaReturnRawElementProvider; every node is a provider with the Simple, Fragment and (the root) FragmentRoot tables, answering control type, name, value, enabled, focusable and focused, automation id, bounds, navigation through the kept tree, and the Invoke, Toggle, RangeValue, Value and ScrollItem patterns, each turned into anEvent::Action; focus changes raiseUIA_AutomationFocusChangedEventIdand structure changesChildrenInvalidatedon the root. The Text pattern (caret and selection read by Narrator inside a field) is left out: fields read as their Value. window/shell.alloy:IFileOpenDialog/IFileSaveDialogshown modal to the window, filters asCOMDLG_FILTERSPEC, the results'IShellItempaths; an OLEIDropTargetregistered withRegisterDragDrop, readingCF_HDROPfiles andCF_UNICODETEXT.- The compiler links
ole32,oleaut32,shell32anduiautomationcoreinto Windows programs (17 libraries in all). - Tests:
tests/files(dialogs and drops headless, under weston and in node's page),ui/tests.alloy(handlers andon_drop);tests/automation.alloyreads a window's tree back throughIUIAutomationand presses, toggles and sets through the patterns, built here for Windows and run there by hand, as the window tests are. - Sizes: the counter grows to about 1.55 MB native and 1.25 MB on the web, whose budgets went to 1.6 and 1.3 MB.
**F6c as built** (2026-10-13):
pkg::alloy::dbus(dbus, packed byscripts/pack.shbeforewindow, which imports it):wire.alloythe marshalling (every basic type, arrays, structs, variants and dictionaries as oneValueenum, aligned from the message's start, little-endian, read back either way),dbus.alloymessages (Message::call,Message::signal,reply,error) and theConnection:session(),open(address)over a Unix socket (unix:path=andunix:abstract=), SASLEXTERNAL,Hello,callwaiting for its reply while queueing what else arrives,send,receivenever blocking,wait,add_match,request_name,get_property, andfd()for a loop to poll.dbus/tests.alloychecks the wire format;dbus/check.alloytalks to a real bus.- File dialogs (
window/portal.alloy): xdg-desktop-portal'sFileChooser.OpenFile/SaveFilewith the title, filters,multipleandcurrent_name, itsRequest.Responsesignal read from the session bus the loop polls,file://URIs turned into paths. With no portal a dialog answers at once with no files.dbus/fake_portal.alloyanswers dialogs for the tests. - AT-SPI (
window/atspi.alloy): whenorg.a11y.Statussays accessibility or a screen reader is on, the window joins the accessibility bus (org.a11y.Bus.GetAddress), embeds its application in the registry's desktop (Socket.Embed) and givesEvent::AccessRequested; each node is an object under/org/a11y/atspi/accessible/answeringAccessible(role, name, states, children, parent, index),Component(extents, in window coordinates, since Wayland gives no position),Action(press, toggle, focus),Value,TextandEditableText(a field's text, caret and selection, setting its contents), and the properties. Changes go out asObject:StateChanged,PropertyChange,ChildrenChangedand focus signals.tests/atspireads its own window's tree through the registry as Orca does, then presses, toggles and sets values, under weston on the tests' own bus with at-spi2-core's launcher. - Wayland drops:
wl_data_device'senter,motion,leaveanddrop, offers oftext/uri-listread as files and text as text, through the pipe the clipboard already polls; untested here, weston's headless backend having no seat to drag from. scripts/test.shruns every window program on a session bus of its own (adbus-daemonthat starts no service on demand), never the desktop's.- Sample
samples/viewer.alloy: PNGs opened through the dialog or dropped, shown one at a time, turned gray or flipped, saved again (samples/images/png.alloyreads 8-bit and palette PNGs through its own inflate and writes stored deflate blocks;images/check.alloycompared it with zlib on the system's PNGs). - Sizes: D-Bus, AT-SPI, the portal and the data device add about
260 KB to a native Linux program using
window(hello 1.57 MB, the counter 1.83 MB, the canvas's startup program 1.15 MB; budgets 1.6, 1.85 and 1.2 MB, the last raised with F7a), nothing on the web. - On the way the checker learnt that a
|&x|capture into a temporary subject, kept past its statement, dangles (section 5.5), which the viewer's reader met as freed memory.
**F7a as built** (2026-10-13), not yet run on a Mac:
window/objc.alloy(nowobjc):Objc::load()openslibobjc.A.dylib(on Linux libobjc2'slibobjc.so.4.6) and keeps the runtime's functions;send<F>()andsend_struct<F>()readobjc_msgSend(orobjc_msgSend_streton x86-64) as a prototype;sel,class, and helpers for the common shapes (call,call_with,call_integer,call_bool,integer,boolean,number,make,release,string,text_of). Classes:subclass(the registered class when the name exists),method(a C function),method_with(a block holding a state pointer, throughimp_implementationWithBlock),add_state/state/set_state(an instance variable),adopt. Blocks are global blocks in C's heap (block,block_state,free_block), never copied by the runtime. A lambda passed where a genericF: CFunctionis expected does not take a C function type from it, so methods are written as typed constants first:const f: extern (c_pointer, c_pointer, i64) -> i64 = (this, _, x) => x;.window/objc_check.alloy(nowobjc/check.alloy) runs on libobjc2 inscripts/test.sh: a root class made while running, messages with integers, doubles, floats,BOOLs, a 32-byte struct throughobjc_msgSend_stretand a 16-byte one in registers, methods as blocks holding Alloy values, an instance variable, a class found again by name.window/appkit.alloy,run's choice on both macOS targets: the frameworks open by their paths in/System/Library/Frameworks; classesAlloyView(anNSView: flipped, the mouse, wheel and touchpad, keys and modifiers, the cursor through a tracking area),AlloyWindowDelegate(closing, resizing, the scale, focus) andAlloyApplicationDelegate(quitting asks the program throughCloseRequested; activation once launched), made once a process, their methods blocks reading the running window from a cell in C's heap, which is 0 between windows. The application menu holds Hide, Hide Others, Show All and Quit.[NSApp run]is the loop; closing the window stops it, a posted event makingstop:take effect, andrunreturns.- Two run loop sources on the main thread, in the common modes so they
fire during live resizing too: a Waker's (
Waker::AppKit, which any thread signals throughCFRunLoopSourceSignalandCFRunLoopWakeUp) and the frames', which aCVDisplayLinksignals each refresh while a redraw is wanted and stops when none is. A resize is delivered and drawn at once, inside AppKit's resizing loop. - Keys by their virtual key codes (Events.h's
kVK_), others by the character they write unmodified; text fromcharacterswhen neither Command nor Control is held (input methods and dead keys wait forNSTextInputClientin F7c). Command isModifiers.super, andui's fields take Command for their shortcuts on macOS (shortcutinui/fields.alloy), Control elsewhere. - CPU frames become a
CGImage(sRGB, 32-bit little-endian with the top byte skipped, the same pixels as Wayland's and GDI's) set as the view's layer's contents.Target::AppKitgives the window and view for F7b's Metal surface; the Vulkan device does not open on macOS, so the CPU device draws. - F7c's services answered as nothing until F7c: the clipboard empty, dialogs with no files, the accessibility tree dropped.
scripts/test.shbuilds every sample and test program for both macOS targets;scripts/macos.sh build <dir>builds them in release beside the tests' expected output, andrun <dir> <host>runs the tests on a Mac over SSH.
**F7b as built** (2026-10-13), not yet run on a Mac:
- The Objective-C layer became its own package,
pkg::alloy::objc(objc, its checkobjc/check.alloy), whichwindowandgpuboth import. - MSL (
gpu/shader/msl.alloy) is written from the SPIR-V the compiler makes of the checked WGSL rather than from the syntax tree: the module's types, layouts and structured control flow are settled there, and only what the compiler emits is read (no phi, selections and loops with their merges). Every value is a variable declared at the top of its function; components are read by index, never by swizzle; loops becomewhile (true)with the continuing block repeated before eachcontinue; structs keep their WGSL offsets through padding members, 3-component vectors in them packed; a function takes the resources it and its callees use as parameters. An entry pointnamebecomesalloy_name, with structs of its stage's inputs and outputs and its resources atmetal_index's indices: buffers, textures and samplers each from 0 in the order the entry uses them, vertex buffers after the vertex stage's buffers. #shaderkeeps the MSL in its blob (format version 3) on the macOS targets only;#msl(source)gives it on any target.tests/msl_dump.alloywrites the tests' and the canvas's, whichscripts/test.shcompares withtests/golden/msland compiles as C++17 with clang againsttests/metal/metal_stdlib, a stand-in declaring the vector, matrix, packed, array and texture types, their operators and the functions MSL uses: it catches unknown names, wrong arities and mismatched types, not what Metal alone checks.gpu/metal/metal.alloy,Backend::Metal, whichAutomatictakes on macOS:MTLCreateSystemDefaultDevice, one queue, buffers and textures in private storage, writes staged into a shared buffer and copied by a blit at the start of the next command buffer, reads through a shared buffer after waiting, at most three command buffers in flight. Bind groups keep their bindings and are bound per stage at each draw or dispatch, as are vertex buffers, whose index depends on the pipeline. Objects are released at once, command buffers keeping what they use.- Surfaces: a
CAMetalLayer(BGRA8, not framebuffer-only, so copies reach it) set as the window's view's layer, each frame a drawable whose texture takes the surface's one texture slot, presented by a command buffer of its own. tests/scenesandtests/canvastakemetal;scripts/macos.sh runchecks both against the goldens on a Mac.
**F7c as built** (2026-10-13), not yet run on a Mac:
pkg::alloy::objcgained blocks returning structs larger than 16 bytes (struct_method_with,struct_block): the block carries its type encoding and, on x86-64,BLOCK_USE_STRET, so a method made of it is called throughobjc_msgSend_stret(block_signatureturns a method's encoding into the block's);bool_code()givesBOOL's encoding,Bon ARM64 andcon x86-64. The check on libobjc2 calls such a method and prints its signature.window/cocoa.alloy: Foundation's points, sizes, rectangles and ranges, arrays, and the conversions between the view's pixels and the screen's points and between UTF-8 offsets and NSString's UTF-16 ones.- Input methods:
AlloyViewis anNSTextInputClient. While the program takes text (set_text_input), a key goes tointerpretKeyEvents:after itsKeyevent;insertText:givesText,setMarkedText:givesPreedit(its caret at the end of the input method's selection),unmarkTexttypes the composition as it is, and commands (insertNewline:and the others) do nothing, theKeyevents having carried them. A key pressed during a composition is the input method's alone, as on Windows. The candidates go belowfirstRectForCharacterRange:, the text input's area on the screen; moving it invalidates the input context's coordinates and taking no text discards a composition. With no text input, text still comes from the key'scharacters. - The menu bar gains an Edit menu (Cut, Copy, Paste, Select All with
Command's keys); the view takes its commands as the key events they
stand for (
Character('c')withsuper), since AppKit gives Command shortcuts to the menu before the view. - The clipboard is the general
NSPasteboard's string (setString:forType:,stringForType:). Dialogs areNSOpenPanelandNSSavePanelrun modal once the handler returns, as on Windows: the title as title and message, the filters' extensions as allowed types unless a pattern takes any file, several files when asked, the proposed name; paths from the chosen URLs. - Drops: the view registers for file URLs and strings and copies them;
draggingEntered:,draggingUpdated:,draggingExited:andperformDragOperation:giveDragEntered,DragMoved,DragLeftandDropped, files read asNSURLs throughfilePathURL(Finder gives file reference URLs), else the text. - VoiceOver (
window/nsaccessibility.alloy): the view stands for the tree's root (AXGroup, its label the root's), and every other node gets anAlloyAccessibilityElement, a subclass ofNSAccessibilityElementholding the node's id, made as it is reached and released once the node is gone. Nodes of no role are left out, their children standing in for them. Roles map toAXButton,AXCheckBox,AXSlider,AXTextField/AXTextArea,AXStaticText(a label's text as its value),AXImage,AXList,AXScrollAreaandAXGroup; values are a checkbox's state and a slider's value as numbers, with its limits, and a field's text with its selection in UTF-16 units. Frames come from the nodes' bounds on the screen, hit tests and the focused element from the tree. Pressing, incrementing, decrementing, setting a value, focusing and selecting are queued asActions and given once VoiceOver's call returns, through a third run loop source;isAccessibilitySelectorAllowed:offers each only on the nodes that take it. The first question about the view givesAccessRequested; updates postAXValueChanged,AXTitleChanged,AXLayoutChanged,AXFocusedUIElementChangedandAXUIElementDestroyedfor the elements VoiceOver has. - Every sample and test program builds for both macOS targets; nothing of it has run on a Mac.
**Fonts arriving** (2026-10-14; decisions/F10.md, question 6A):
Event::FontsArrivedon the web once a font a program fetched for fallback (pkg::alloy::text'sfonts.fetch) arrives: text'sbrowser.web.jsdispatches analloyfontsarrivedevent on the page, which this package's listens to, so text knows nothing of windows. Never sent natively, wherefetchreads the file at once.uilays every text out again on it; a program drawing withdrawalone lays its own out again.- Tests:
tests/fetch.alloylays its text out on the first frame and on the event only, in node's page (whose fetch now answers a fifth of a second late, past the first frames) and under weston.
**F11a as built** (2026-10-15; decisions/F11.md, question 7A and "Accessibility on each platform"):
- The window's clock:
window.now(), monotonic from when the window opened;Event::Redrawcarries the frame's time on it (on the web therequestAnimationFrametime).window.wake_at(at)sets the one deadline (Noneclears it), answered byEvent::Timerat or after it: Wayland'spolltimeout, Win32'sSetTimer(WM_TIMER, at most about 24 days ahead), AppKit'sCFRunLoopTimer, the page'ssetTimeout. A headless window's clock moves only as a script'sRedraw(at)says, delivering theTimerpassed on the way, and never goes back. With no deadline nothing wakes. - Roles
Dialog,Alert,Menu,MenuItemandTooltip;Semanticsgainsmodal,expanded: Option<bool>anddescription; actionsExpand,CollapseandDismiss;Key::Menu.window.announce(text, assertive)speaks without the tree. - UI Automation: Menu, MenuItem and ToolTip control types, dialogs and
alerts panes with
IsDialog, the description asHelpTextandFullDescription, the ExpandCollapse pattern, announcements throughUiaRaiseNotificationEvent(assertive ones asImportantAll, polite ones asCurrentThenMostRecent). No Window pattern, so Narrator's close goes through Escape. - AT-SPI: dialog, alert, menu, menu item and tool tip roles; states
MODAL,EXPANDABLE,EXPANDEDandCOLLAPSED;Description; announcements as theAnnouncementsignal, polite or assertive. - The web:
dialog,alertdialog,menu,menuitem,tooltip;aria-modalwith the content before itinert,aria-expanded,aria-haspopup,aria-description; announcements intostatusandalertlive regions. The fake DOM's reader says them (tests/access). - macOS (built only):
AXMenu,AXMenuItem,AXHelpTag, dialogs with the subrolesAXApplicationDialogandAXApplicationAlertDialog, modal and expanded states, the description as help,accessibilityPerformCancelasDismiss, announcements posted with their priority. - Tests: the clock in
window/tests.alloy;tests/frameswaits for a timer;tests/access,tests/atspiandtests/automation(by hand on Windows) read a menu, a modal alert and an announcement.
**F11b as built** (2026-10-15; decisions/F11.md, "Choices" and "Accessibility on each platform"):
- Roles
ComboBox,ListBox,ListOption,RadioGroupandRadioButton;Semanticsgainsselected: Option<bool>andposition: Option<[u32 : 2]>(from 1, and the count);Action::Select. What opens a popup says so byexpandedalone: a combo box's is a list box, a button's or a menu item's a menu. - UI Automation: ComboBox with ExpandCollapse and a read-only Value,
List with the Selection pattern (
GetSelectiona SAFEARRAY of the selected options' providers, through com's newunknowns), ListItem and RadioButton with SelectionItem (SelectandAddToSelectionasAction::Select, the container their parent),PositionInSetandSizeOfSet; an option or radio becoming selected raisesSelectionItemIsSelectedandElementSelected. - AT-SPI: combo box (with the Text interface reading its value), list
box, list item and radio button roles, a radio group a panel; states
SELECTABLE,SELECTEDandHAS_POPUP;posinsetandsetsizeattributes;StateChangedselected. - The web:
combobox(its value as its text),listbox,option,radiogroup,radio;aria-selected,aria-posinset,aria-setsize,aria-haspopuplistboxormenu. - macOS (built only):
AXPopUpButton,AXMenuButtonfor a button opening a menu,AXListofAXStaticTextoptions,AXRadioGroup,AXRadioButton;isAccessibilitySelected,setAccessibilitySelected:asSelect,accessibilityPerformShowMenuasExpand. - Tests:
tests/accesssends a combo box, a list box and a radio group, which node's page prints;tests/atspiandtests/automation(by hand on Windows) open aSelect, choose an option and a radio.
**F11c as built** (2026-10-15; decisions/F11.md, "Screens", question 6B, and "Accessibility on each platform"):
- Roles
TabListandTab(selected,position): UI Automation's Tab with the Selection pattern and TabItem with SelectionItem (and its selection events); AT-SPI's page tab list and page tab, a tabSELECTABLE,SELECTEDand pressed by its action; ARIA'stablistandtabwitharia-selected; macOS (built only) anAXTabGroupofAXRadioButtons of subroleAXTabButton, their value 1 when selected,setAccessibilitySelected:asSelect. - The page's history:
HistoryEntry { depth, path },window.set_history(depth, path)(kept, and sent once a change),window.start_path()andEvent::Navigated. On the webbrowser.web.jsmarks the page's entries with their depth (history.state.alloyDepth): a deeper entry is pushed, a level each, at#<path>, a shallower one reached byhistory.go, whosepopstateit waits for before following again, a new path at the same depth replaces the address, and an empty path keeps it. Apopstateit did not cause givesNavigatedwith the entry's depth (one deeper for an entry it did not make, as an address typed) and the fragment's path. Headless,Replay.historykeeps each entry set; elsewhere nothing has a history. - Tests: the history headless in
window/tests.alloy;tests/historyin node's page, whose fakehistoryopens at#/startand a person goes back twice and forward once, and under weston, which has none;tests/accesssends a tab list.
**F11d as built** (2026-10-15; decisions/F11.md, "Dates and times" and "Accessibility on each platform"):
- Roles
GridandGridCell;Semanticsgains `cell: Option<[u32 : 2]>` (a cell's row and column, from 0, which each tree's rows and counts come from) andcurrent(today among a calendar's days). - UI Automation: Calendar with the Grid (
GetItem, row and column counts), Table (no headers, row major) and Selection patterns, DataItem with GridItem (its place, spans of one, the grid) and SelectionItem;currentasAriaPropertiescurrent=date. - AT-SPI: calendar with the Table interface (
NRows,NColumns,GetAccessibleAt,GetIndexAt,GetRowAtIndex,GetColumnAtIndex,IsSelected), table cell with TableCell (Position, spans,Table,GetRowColumnSpan), clicked by its action;currentas the attributecurrent:date. - The web:
grid, its cells put inrowelements the page makes from their rows,gridcell,aria-current="date". - macOS (built only):
AXTableofAXRowelements standing for no node, made per grid and row and released with the grid, holding theAXCells;accessibilityRows, row and column counts and index ranges;currentnot given. - Tests:
tests/accesssends three days in two rows, which node's page prints. - Question 19A (2026-10-16): a button with a value, a date picker's
date, gives it in every tree: UI Automation's Value pattern, read
only; AT-SPI's Text interface, as a combo box's; the web's
aria-label"<label>, <value>";AXValueon macOS, as before.tests/access,tests/atspiandtests/automationread it.
**F11e as built** (2026-10-15; decisions/F11.md, "Reduced
motion"): window.reduced_motion(), read as the window opens, and
Event::ReducedMotion(bool) as it changes. Linux: the settings portal
(org.freedesktop.portal.Settings.Read, a second at most) for GNOME's
enable-animations, else KDE's AnimationDurationFactor at 0, and its
SettingChanged signal, the portal's session bus now joined as the
window opens; Windows: SPI_GETCLIENTAREAANIMATION and
WM_SETTINGCHANGE; macOS (built only): NSWorkspace's
accessibilityDisplayShouldReduceMotion and its notification, observed
by the window's delegate; the web: `matchMedia("(prefers-reduced-motion:
reduce)") and its change`; headless: off but as a script's event says.
The test portal (dbus/fake_portal.alloy) answers the setting.
**F12a as built** (2026-10-15; decisions/F12.md, "Timers"):
on the web the page shown again (visibilitychange to visible, the
page event Timer with a set) gives an Event::Timer whether or not
the deadline has come, a hidden page's setTimeout running late; the
fake page's ALLOY_PAGE=shown hides and shows it. A headless run's
Replay counts wakes, the deadlines wake_at changed.
**F12c as built** (2026-10-16; decisions/F12.md, "Waiting in ui"):
- The page's
Waker::Page, whichrun_browsergives the window: itswake()posts a message on aMessageChannel(al_window_wake), once for wakes close together, which comes back as the page event Woken (24) and anEvent::Woken, the next task, before the next frame; the channel closes with the window. Role::ProgressBar(UI Automation's ProgressBar, its RangeValue read only; AT-SPI'sprogress barwith the Value interface; ARIA'sprogressbarwitharia-valuenow;AXProgressIndicator), its value inrangeand as text invalue, none while not known; andSemantics.busy(UIA'sAriaPropertiesbusy=true, aftercurrent=when both, AT-SPI'sBUSYstate with itsStateChangedevent,aria-busy, andisAccessibilityElementBusyfor AXElementBusy, not yet run on a Mac).tests/accessgives a progress bar and a busy list, read by node's fake screen reader;tests/atspireads both through at-spi2-core.- The fake page's
fetch(tests/web/dom.mjs) hands a URL naming a server to node's own fetch.
**F12d as built** (2026-10-16; decisions/F12.md, "Storage"):
WindowConfig.app (default "", app_name() giving the title then),
kept as Window.app and sent as the toplevel's app_id on Wayland,
window.app_name() giving it to pkg::alloy::ui's store as the app starts
(2026-10-17, question 23B); the fake page's localStorage, kept in the file ALLOY_PAGE_STORAGE
names and refusing every write with ALLOY_PAGE=full.
**Closing refused** (2026-10-17; decisions/showcase.md,
question 6A): Event::CloseRequested comes on every platform and the
window stays open until the program calls close (Wayland's
xdg_toplevel.close, Win32's WM_CLOSE, AppKit's windowShouldClose:
and applicationShouldTerminate: answered no, as since F1 and F7a);
the web gains it from beforeunload, the page's handler giving the
event and, when the program did not close its window, asking the
browser to ask the person (its own words: the most a page may do).
Navigated now sets the window's history entry, so an entry the
program sets after it goes to the page only when it differs: a program
refusing to go back is put back deeper. tests/history in node's page
leaves the page, which the program refuses.
**Fields in error** (2026-10-17; showcase.md, question 11A):
Semantics.invalid, a field whose value is refused, its description
saying why: UI Automation's IsDataValidForForm false and invalid=true
in AriaProperties, AT-SPI's INVALID_ENTRY state (with its
StateChanged), aria-invalid on the web. NSAccessibility has no
property for it (the old API's AXInvalid attribute only), so on macOS
the message as the element's help is what VoiceOver says, not yet run
on a Mac. tests/access gives a field in error (read in node's page),
tests/atspi and tests/automation an empty field "Required".
**Checked menu items** (2026-10-17; showcase.md, question 12A):
Role::MenuItemCheckbox with checked: UI Automation's MenuItem with
the Toggle pattern, AT-SPI's CHECK_MENU_ITEM with its CHECKABLE and
CHECKED states, ARIA's menuitemcheckbox with aria-checked, and
macOS's AXMenuItem with the value 0 or 1. tests/access gives one.
**Secret input** (2026-10-20; decisions/F13.md, question
13A): Semantics.secret, a field hiding what is typed, its value the
dots it shows: UI Automation's IsPassword (the Value pattern giving
the dots), AT-SPI's PASSWORD_TEXT role (its Text the dots), on the
web the layer's node an <input type="password"> holding the dots, as
a page's own password field reads (no ARIA role says it), and on
macOS the AXSecureTextField subrole, not yet run on a Mac.
window.set_secret_input(secret) tells the input method: Wayland's
text-input-v3 content type (purpose password, hints hidden_text and
sensitive_data; enabled again to go back to normal), on Windows no
input context associated, as an ES_PASSWORD edit has (characters
still as WM_CHAR), on the web a hidden <input type="password">
taking the keyboard instead of the textarea, and on macOS keys
skipping the input method and EnableSecureEventInput held while the
window has the focus, as NSSecureTextField does. Headless:
Replay.secret_input. tests/access gives a password's field.
**F14a as built** (2026-10-20; decisions/F14.md, "Right to
left"): WindowConfig.languages lists the languages an app has, its
first the one it falls back to (["en"] by default), which
pkg::alloy::ui chooses among. window.set_language(tag, right_to_left)
says what its content is in, kept as language() and
right_to_left() and taken by each platform as it asks
(Requests.language): UI Automation's Culture property, the LCID
LocaleNameToLCID gives, on every node; AT-SPI's GetLocale and
Locale (ar_EG.UTF-8, as POSIX writes it); on the web the layer's
lang and dir; on macOS the view's
userInterfaceLayoutDirection (NSAccessibility has no language of
its own for an element), not yet run on a Mac. Semantics.right_to_left
marks a node reading the other way than the window, the web's dir
on it (UI Automation and AT-SPI have no direction for a node).
Headless: Replay.language and right_to_left. Tests: tests/access
(lang, dir and a node's own), tests/atspi (the locale of an app
in British English), window/tests.alloy (the replay keeping the
last).
**F14b as built** (2026-10-20; decisions/F14.md, "Text for
screen readers"): AccessNode.text, a TextMap (graphemes' starts and
edges, word starts, lines with their boxes in the node's pixels and
direction, one TextFormat) that pkg::alloy::ui sends with a field and
a text of several lines while a screen reader reads, never on the web;
maps compare by revision alone. text_ranges.alloy answers from one
for every platform: unit_at and moved by TextUnit (a character a
grapheme, a word to the next one's start, a line as drawn, a paragraph
to a line break, the document), boxes (one a line, more where the
direction changes, the caret's a pixel wide), offset_at,
grapheme_at, visible_lines, clamped, and TextMap::plain for a
value no layout was sent for. A secret field's map is of its dots.
- UI Automation (
uia.alloy, not yet run on Windows):ITextProviderandITextProvider2on a node with a map, each range anITextRangeProviderof its own holding the node and two byte offsets clamped to the text at each call, the attributes and the events of F14.md's list; ranges whose provider is gone answerUIA_E_ELEMENTNOTAVAILABLE.tests/windows/com_layout.shchecks the three tables' slots and those the client intests/automationcalls against MinGW's headers;tests/automationreads a note by line and word, its rectangles, its font, a field's caret range, a word selected throughSelectand theTextSelectionChangedthat follows (its expected output written by hand), andwindows-tests.ps1lists the steps to try with Narrator and NVDA innotes.exe, which gains an Arabic note. - AT-SPI (
atspi.alloy):Textcompleted, offsets in code points:GetStringAtOffsetby granularity (sentences as paragraphs),GetTextAtOffset,BeforeandAfterby boundary,GetCharacterAtOffset,GetCharacterExtentsandGetRangeExtentsin window coordinates,GetOffsetAtPoint, the selection's five methods (one selection, a field's),GetAttributes,GetAttributeRun,GetDefaultAttributesandAttributeSet,GetAttributeValue(family-name,sizein points,weight,fg-color,language,direction,editable),ScrollSubstringTo, and the signalsTextChanged:deleteandinsert(the text between a common start and end),TextCaretMovedandTextSelectionChanged. A combo box's and a button's value answer through a plain map.tests/atspireads a wrapped note and a field through at-spi2-core. The window reaches AT-SPI's handling of trees throughWindow.atspi, whichupdate_accesssets, and Text's answers throughAtspi.texts, which the first tree taken sets, so a program sending no tree (hello world) links neither: 63.5 KB of it. - macOS (
nsaccessibility.alloy, built for both targets, not yet run on a Mac):accessibilityInsertionPointLineNumber,LineForIndex:,RangeForLine:,StringForRange:,AttributedStringForRange:(the font's family and size, the color,NSAccessibilityLanguageTextAttribute),FrameForRange:,RangeForPosition:,RangeForIndex:(graphemes),StyleRangeForIndex:,VisibleCharacterRangeandSelectedText, in UTF-16 units, andAXSelectedTextChangedwhen a selection moves. - Tests:
window/tests.alloyover maps written by hand (every unit at both ends, moves past the ends, boxes across a change of direction, points between lines and past the text).
**R6f as built** (2026-10-26; REFOCUS.md, question 3B, and the portal and drops under pkg::alloy::ui_app): what a program installs.
window.install_access()(pkg::alloy::ui_access calls it) andwindow.install_files()(ui_app'sFiles, andopen_filesandsave_filethemselves) each push aStartinto the requests: one variant a platform, holding the function that platform starts the part with once the handler returns. That function sets the platform'sParts, the function values its loop and window procedure call from then on, so a program never installing either reaches none of their code: on Linux AT-SPI and D-Bus, the portal and the data device's drags and drops; on Windows UI Automation (Uiamade at the start, WM_GETOBJECT passed on to Windows before), the OLE drop target and the shell's dialogs; on macOS the view's accessibility methods and the elements' class (added to the registered class at the start),MacAccess, the dragging methods and the panels; on the web the "Turn on accessibility" button (al_window_access_start, the layer's code inlayer.web.jssince 14B) and drops reaching the program (al_window_files_start; before, the page refuses them), the layer's JSON and the dialogs. Headless windows need nothing started.- Without
install_access,update_accessandannouncedo nothing and nothing givesEvent::AccessRequested;set_languagestill keeps the language (a replay'slanguage) but reaches no screen reader. Withoutinstall_files, a drag over a Wayland window is let go unaccepted, and a dropped file opens nothing in the page. - Reduced motion on Linux is read through the settings portal only
once either is installed (
start_portal, thenEvent::ReducedMotionif it is on), with screen readers alone throughPortal::read_settings, which leaves the file chooser's answers out; until then a Wayland window reads it as off. Windows, macOS and the web read it as before. - AT-SPI starts after the first handler installing it, no longer as
the window opens;
Window.atspi(F14b's indirect tree) is gone, its work done by the start. - Tests:
window/tests.alloyinstalls in its tree's replays and checks one not installing;tests/accessandtests/filesinstall.
**14B as built** (2026-10-27; REFOCUS.md, question 14): the page's
accessibility layer in a module of its own, layer.alloy with
layer.web.js, whose externs only the installed layer calls, so a web
program bundles its JavaScript only when it installs screen readers;
it reaches the canvas, its scale, events, keys and focus through
alloy.page, which browser.web.js fills, and records there the
elements it adds (removed as the window closes) and the layer (part of
the window when focus moves). The counter's glue 9.8 KB smaller.
SizePointAreaWindowConfigWindowConfig::titledapp_nameModifiersModifiers::noneKeyKeyEventPointerButtonButtonEventScrollEventEventHistoryEntryPreeditFileFilterFileFilter::ofFileDialogChosenFileChosenDraggedDropRoleSemanticsAccessRangeAccessNodeTextMapequalsTextLineTextFormatTreeUpdateActionActionRequestAnnouncementAccessTreeAccessTree::emptyapplytry_parent_ofnode_atCursorWakerAppKitWakerTargetWaylandTargetWin32TargetAppKitTargetWindowapp_nameset_cursorcursorinstall_accessinstall_filesupdate_accessannounceset_clipboardrequest_clipboardopen_filessave_filesave_bytesnowwake_atset_historyset_languagelanguageright_to_leftreduced_motionstart_pathwakerwakesizescalefocusedtitleset_titlerequest_redrawcloseset_text_inputset_secret_inputpresenttargetsurface_presentedrun
type Sizesource
exp type Size = struct
A size in pixels.
Fields
exp width: u32exp height: u32
type Pointsource
exp type Point = struct
A position in pixels from the window's top left.
Fields
exp x: f32exp y: f32
type Areasource
exp type Area = struct
A rectangle in pixels from the window's top left.
Fields
exp x: f32exp y: f32exp width: f32exp height: f32
type WindowConfigsource
exp type WindowConfig = struct
How the window opens.
Fields
exp title: &[u8]exp size: Sizein logical pixels
exp resizable: boolexp app: &[u8] = &""the app's name, which its data is kept under (std::storage) and Wayland's app_id; the title when empty
exp languages: &[&[u8]] = &[&"en"]the languages the app is written in, as BCP 47 tags, its first the one it falls back to:
uilays it out in the first of the system's preferred languages it has, and in that one's direction
Functions
fn WindowConfig::titledsource
exp fn WindowConfig::titled(title: &[u8]) -> WindowConfig
A resizable window of 800 by 600 logical pixels.
fn app_namesource
exp fn app_name(self config: &WindowConfig) -> &[u8]
The name the app's data is kept under: its own, else the title.
type Modifierssource
exp type Modifiers = struct
The modifier keys held during an event.
Fields
exp shift: boolexp control: boolexp alt: boolexp super: boolthe Windows or Command key
Functions
fn Modifiers::nonesource
exp fn Modifiers::none() -> Modifiers
No modifier key held.
type Keysource
exp type Key = enum
A key, by what the keyboard layout makes of it: the same physical key
is Character('z') on a QWERTY layout and Character('y') on a QWERTZ
one. Text typed comes separately, as Event::Text.
Variants
Character: u32a key writing a character, as a Unicode code point, lower case:
Character(' ')for the space barEnterEscapeBackspaceTabDeleteInsertLeftRightUpDownHomeEndPageUpPageDownFunction: u8F1 to F24
ShiftControlAltSuperCapsLockMenuthe context menu's key
Unknown: u32the platform's code for the key
type KeyEventsource
exp type KeyEvent = struct
A key pressed or released.
Fields
exp key: Keyexp pressed: boolexp repeat: boola press repeated while the key is held
exp modifiers: Modifiers
type PointerButtonsource
exp type PointerButton = enum
A mouse button, or a pen's or touchpad's equivalent.
Variants
LeftRightMiddleBackForwardOther: u32
type ButtonEventsource
exp type ButtonEvent = struct
A button pressed or released where the pointer is.
Fields
exp pressed: boolexp position: Pointexp modifiers: Modifiers
type ScrollEventsource
exp type ScrollEvent = struct
A wheel's or touchpad's scrolling, positive down and to the right.
Fields
exp delta: Pointexp precise: boolthe delta is in physical pixels (a touchpad), not in lines (a wheel's notches)
exp modifiers: Modifiers
type Eventsource
exp type Event = enum
What happens to the window, in the order it happens.
Variants
Resized: Sizethe window's size changed, and when it opens; a Redraw follows
Scaled: f32the scale changed, and when it opens if not 1; a Resized follows
Redraw: Durationthe window needs drawing: when it opens, after a resize, and after
request_redraw, paced by the display; the frame's time on the window's clock (now)Timerthe time
wake_atasked for has comeCloseRequestedthe user asked to close the window (on the web, to leave or reload the page); it closes when the program calls
close, and a program not calling it keeps it open (on the web the browser then asks the person whether to leave, in its own words)Focused: boolPointerMoved: PointPointerLeftButton: ButtonEventScroll: ScrollEventKey: KeyEventText: Stringtext typed, as UTF-8: a character, or several when an input method commits a composition
Preedit: Preeditthe composition an input method has in progress, which the program shows at the caret in place of the last one, until a Text commits it; an empty one ends it, and comes before the Text
Wokenanother task woke the loop through the window's
Waker; wakes close together may come as oneClipboard: Stringthe clipboard's text, after
request_clipboard; empty when it holds noneAccessRequesteda screen reader started reading the window: the program sends its whole accessibility tree, then its changes (
update_access)Action: ActionRequestwhat a screen reader asks of a node of the tree
FilesChosen: Chosenthe files a dialog
open_filesorsave_fileshowed gave, none when cancelledDragEntered: Draggedsomething dragged from another program came over the window, moved over it, left it, or was dropped on it
DragMoved: PointDragLeftDropped: DropFontsArrivedon the web, a font the program fetched (pkg::alloy::text's
fonts.fetch) has arrived: text laid out before it may show boxes it now covers, to lay out again; never sent elsewhere, where a fetch reads the file at onceon the web, the browser's Back or Forward, or an address typed, moved to another entry of the page's history (
set_history)ReducedMotion: boolthe system's setting asking for less motion changed: whether it asks now (
reduced_motion)
type HistoryEntrysource
exp type HistoryEntry = struct
Where a program is in the page's history: how deep in its own
entries, from 1, and its path, which the address shows after a #
(/events/42), empty for none.
Fields
exp depth: u64exp path: String
type Preeditsource
exp type Preedit = struct
Text an input method is composing, not yet typed.
Fields
exp text: Stringexp cursor: u64the input method's caret in the text, in bytes
type FileFiltersource
exp type FileFilter = struct
A kind of file a dialog offers: its name and its patterns, *.png.
Fields
exp name: Stringexp patterns: Vector<String>
Functions
fn FileFilter::ofsource
exp fn FileFilter::of(name: &[u8], patterns: &[&[u8]]) -> FileFilter
type FileDialogsource
exp type FileDialog = struct
What a file dialog shows.
Fields
exp title: String = String::empty()exp filters: Vector<FileFilter> = Vector<FileFilter>::empty()exp multiple: bool = falseopening: more than one file
exp name: String = String::empty()saving: the name proposed
type ChosenFilesource
exp type ChosenFile = struct
A file chosen or dropped: its name, and on the desktop its path, on the web its bytes when opened or dropped (a page reaches no paths).
Fields
exp name: Stringexp path: Option<String> = ::Noneexp bytes: Option<Vector<u8>> = ::None
type Chosensource
exp type Chosen = struct
The files a dialog gave, for the request open_files or save_file
returned.
Fields
exp request: u64exp files: Vector<ChosenFile>
type Draggedsource
exp type Dragged = struct
What is being dragged over the window, where.
Fields
exp position: Pointexp files: boolexp text: bool
type Dropsource
exp type Drop = struct
What was dropped on the window, where.
Fields
exp position: Pointexp files: Vector<ChosenFile>exp text: Option<String>
type Rolesource
exp type Role = enum
What a node of the accessibility tree is to a screen reader.
Variants
Unknownnothing a screen reader shows; its children stand in for it
WindowGroupLabelButtonCheckBoxSliderTextInputImageListListItemScrollViewDialoga layer above the content (decisions/F11.md): a dialog, an alert asking for an answer, a menu and its items, a tooltip
AlertMenuMenuItemTooltipComboBoxchoices (F11b): a closed list showing the chosen item, opening a list box of options; radio buttons in a group
ListBoxListOptionRadioGroupRadioButtonTabListscreens (F11c): a row of tabs, one selected, showing a view of its own beside it
TabGriddates (F11d): cells in rows and columns, a calendar's days
GridCellProgressBarwaiting (F12c): how much of a piece of work is done, its range's value, or not known without one
MenuItemCheckboxa menu item turning a setting on or off,
checkedsaying which
type Semanticssource
exp type Semantics = struct
How a node describes itself: its role, what a screen reader says of it and what can be done with it.
Fields
exp role: Role = Role::Unknownexp label: String = String::empty()exp value: String = String::empty()a field's text, a slider's value as said
exp disabled: bool = falseexp focusable: bool = falseexp checked: Option<bool> = ::Nonea checkbox's or a checked menu item's state
exp multiline: bool = falseexp range: Option<AccessRange> = ::Nonea slider's
exp selection: Option<[u64 : 2]> = ::Nonea field's anchor and caret, in bytes
exp modal: bool = falsea dialog keeping the pointer and the keyboard from the rest
exp expanded: Option<bool> = ::Nonewhether what it opens is open: a menu item's submenu
exp description: String = String::empty()what more a screen reader says of it after its label: a tooltip's text
exp selected: Option<bool> = ::Nonewhether an option or a tab is the one selected
exp position: Option<[u32 : 2]> = ::Nonewhere an option or a radio is among its group's, from 1, and how many there are: "2 of 3"
exp cell: Option<[u32 : 2]> = ::Nonea grid cell's row and column, from 0
exp current: bool = falsethe current one of its kind: today among a calendar's days
exp busy: bool = falsewhat it shows is still coming: a list loading
exp invalid: bool = falsea field whose value is refused, its description saying why
exp required: bool = falsea field a form needs filled in
exp secret: bool = falsea field hiding what is typed, a password: its value is the dots shown, one a character
exp right_to_left: Option<bool> = ::Nonea subtree reading in a direction of its own, against what holds it: true right to left (the web's
diron its element)
type AccessRangesource
exp type AccessRange = struct
Fields
exp value: f64exp minimum: f64exp maximum: f64exp step: f64
type AccessNodesource
exp type AccessNode = struct
A node of the tree: its semantics, where it is in the window, in pixels, its children in order, and a field's text or a text of several lines as laid out, while a screen reader reads (text_ranges.alloy).
Fields
exp id: u64exp semantics: Semanticsexp bounds: Areaexp children: Vector<u64>exp text: Option<TextMap> = ::None
Functions
type TextMapsource
exp type TextMap : Equal = struct
A node's text as laid out (decisions/F14.md, F14b): its value, a field's, or else its label, cut into graphemes, words and lines, positions in bytes and pixels from the node's top left. Maps compare by revision alone.
Fields
exp revision: u32changes whenever anything below does
exp graphemes: Vector<u32>where each grapheme starts, then the text's end
exp edges: Vector<[f32 : 2]>each grapheme's left and right on its line
exp words: Vector<u32>where each word starts (UAX #29)
exp lines: Vector<TextLine>exp format: TextFormatone: a node's text has one style
Functions
exp fn equals(self map: &TextMap, other: &TextMap) -> boolexp fn end(self map: &TextMap) -> u32exp fn clamped(self map: &TextMap, at: u32) -> u32exp fn unit_at(self map: &TextMap, text: &[u8], at: u32, unit: TextUnit) -> [u32 : 2]exp fn moved(self map: &TextMap, text: &[u8], at: u32, unit: TextUnit, count: i32) -> Movedexp fn line_of(self map: &TextMap, at: u32) -> u64exp fn boxes(self map: &TextMap, start: u32, end: u32) -> Vector<Area>exp fn offset_at(self map: &TextMap, x: f32, y: f32) -> u32exp fn grapheme_at(self map: &TextMap, x: f32, y: f32) -> Option<u32>exp fn visible_lines(self map: &TextMap, height: f32) -> [u32 : 2]exp fn TextMap::plain(text: &[u8], bounds: &Area) -> TextMap
fn equalssource
exp fn equals(self map: &TextMap, other: &TextMap) -> bool
type TextLinesource
exp type TextLine = struct
A line as drawn: its bytes, its box and whether it reads right to left.
Fields
exp start: u32exp end: u32exp box: Areaexp right_to_left: bool
type TextFormatsource
exp type TextFormat = struct
How a node's text is drawn, as screen readers tell it.
Fields
exp family: Stringexp size: f32in pixels
exp weight: u32exp color: [u8 : 4]red, green, blue, alpha
exp language: StringBCP 47
exp heading: boolexp read_only: bool
type TreeUpdatesource
exp type TreeUpdate = struct
What changed in the tree: the nodes new or changed, whole, and those gone; the root and the focused node as they are now.
Fields
exp nodes: Vector<AccessNode>exp removed: Vector<u64>exp root: u64exp focus: Option<u64>
type Actionsource
exp type Action = enum
What a screen reader asks of a node.
Variants
ClickFocusIncrementDecrementSetValue: StringScrollIntoViewSetSelection: [u64 : 2]anchor and caret, in bytes
Expandopen what it opens: a submenu
CollapseDismissclose a dialog or menu, as Escape does
Selectchoose an option, a radio, a tab or a day
type ActionRequestsource
exp type ActionRequest = struct
Fields
exp node: u64exp action: Action
type Announcementsource
exp type Announcement = struct
What a screen reader is to say at once, without the focus moving: a
toast's text; assertive interrupts what it is saying.
Fields
exp text: Stringexp assertive: bool
type AccessTreesource
exp type AccessTree = struct
The tree as the updates sent so far leave it, with each node's parent.
Fields
exp nodes: Map<u64, AccessNode>exp root: u64exp focus: Option<u64>
Functions
fn AccessTree::emptysource
exp fn AccessTree::empty() -> AccessTree
fn applysource
exp fn apply(self tree: &var AccessTree, update: TreeUpdate)
fn try_parent_ofsource
exp fn try_parent_of(self tree: &AccessTree, id: u64) -> Option<u64>
The node holding a node, none for the root or one not in the tree.
fn node_atsource
exp fn node_at(self tree: &AccessTree, from: u64, point: Point) -> Option<u64>
The deepest node under from holding the point, in the window's
pixels, the last child holding it at each level.
type Cursorsource
exp type Cursor = enum
How the pointer looks over the window.
Variants
ArrowHandover something to click
Textover text to select or type into
type Wakersource
exp type Waker = enum
Wakes a window's event loop from another task (window.waker()), its
handler then given an Event::Woken: tasks finishing work tell the
window this way. Copied to as many tasks as need it; one woken after
its window closed does nothing.
Variants
Nonea headless window, which no other task wakes
Eventfd: i32Wayland's loop polls it beside the compositor's socket
Win32: c_pointerthe HWND, posted a message
AppKit: AppKitWakerPagethe page's, which a callback of the browser's wakes: a message posted to it, taken before the next frame
Functions
type AppKitWakersource
exp type AppKitWaker = struct
The main run loop's source a Waker signals on macOS, and the CoreFoundation functions signalling it, which any thread may call.
type Targetsource
exp type Target = enum
The native objects a GPU surface draws into, for pkg::alloy::gpu.
Variants
Nonea headless window, or one only
presentdraws intoWayland: WaylandTargetWin32: Win32TargetAppKit: AppKitTargetCanvas: u32the page's canvas, marked
data-alloy-windowwith the number
type WaylandTargetsource
exp type WaylandTarget = struct
Fields
exp display: c_pointerthe wl_display
exp surface: c_pointerthe wl_surface
type Win32Targetsource
exp type Win32Target = struct
Fields
exp instance: c_pointerthe HINSTANCE
exp window: c_pointerthe HWND
type AppKitTargetsource
exp type AppKitTarget = struct
Fields
exp window: c_pointerthe NSWindow
exp view: c_pointerits content view, an NSView whose layer is drawn into
type Windowsource
exp type Window = struct
The window the handler is given with each event. What the handler asks of it takes effect once the handler returns.
Functions
exp fn app_name(self window: &Window) -> &[u8]exp fn set_cursor(self window: &var Window, cursor: Cursor)exp fn cursor(self window: &Window) -> Cursorexp fn install_access(self window: &var Window)exp fn install_files(self window: &var Window)exp fn update_access(self window: &var Window, update: TreeUpdate)exp fn announce(self window: &var Window, text: String, assertive: bool)exp fn set_clipboard(self window: &var Window, text: String)exp fn request_clipboard(self window: &var Window)exp fn open_files(self window: &var Window, dialog: FileDialog) -> u64exp fn save_file(self window: &var Window, dialog: FileDialog) -> u64exp fn save_bytes(self window: &var Window, file: &ChosenFile, bytes: &[u8]) -> boolexp fn now(self window: &Window) -> Durationexp fn wake_at(self window: &var Window, at: Option<Duration>)exp fn set_history(self window: &var Window, depth: u64, path: String)exp fn set_language(self window: &var Window, tag: &[u8], right_to_left: bool)exp fn language(self window: &Window) -> &[u8]exp fn right_to_left(self window: &Window) -> boolexp fn reduced_motion(self window: &Window) -> boolexp fn start_path(self window: &Window) -> &[u8]exp fn waker(self window: &Window) -> Wakerexp fn size(self window: &Window) -> Sizeexp fn scale(self window: &Window) -> f32exp fn focused(self window: &Window) -> boolexp fn title(self window: &Window) -> &[u8]exp fn set_title(self window: &var Window, title: &[u8])exp fn request_redraw(self window: &var Window)exp fn close(self window: &var Window)exp fn set_text_input(self window: &var Window, area: Option<Area>)exp fn set_secret_input(self window: &var Window, secret: bool)exp fn present(self window: &var Window, pixels: &[u32], size: Size)exp fn target(self window: &Window) -> Targetexp fn surface_presented(self window: &var Window)
fn app_namesource
exp fn app_name(self window: &Window) -> &[u8]
The name the app's data is kept under (WindowConfig.app_name()).
fn set_cursorsource
exp fn set_cursor(self window: &var Window, cursor: Cursor)
Shows the cursor while the pointer is over the window.
fn cursorsource
exp fn cursor(self window: &Window) -> Cursor
fn install_accesssource
exp fn install_access(self window: &var Window)
Lets the platform's screen readers reach the window: AT-SPI on Linux
(with the settings portal's wish for less motion), UI Automation on
Windows, NSAccessibility on macOS, and on the web a layer of elements
behind a "Turn on accessibility" button. Until then nothing gives
Event::AccessRequested and update_access and announce do nothing;
a program never calling it links none of them (pkg::alloy::ui_access
calls it).
fn install_filessource
exp fn install_files(self window: &var Window)
Lets files be chosen through the platform's dialogs and dropped on
the window: the desktop portal on Linux (with its wish for less
motion), the shell's dialogs and OLE's drops on Windows, NSOpenPanel,
NSSavePanel and the view's dragging on macOS, the page's file input,
file pickers and drops. open_files and save_file install them;
without, nothing dropped reaches the program, and a program never
installing them links none of them (pkg::alloy::ui_app calls it).
fn update_accesssource
exp fn update_access(self window: &var Window, update: TreeUpdate)
Sends the accessibility tree's changes to the platform's screen readers, after an Event::AccessRequested.
fn announcesource
exp fn announce(self window: &var Window, text: String, assertive: bool)
Has the platform's screen readers say the text, politely or, when
assertive, at once, once the tree's updates are sent.
fn set_clipboardsource
exp fn set_clipboard(self window: &var Window, text: String)
Puts the text on the clipboard.
fn request_clipboardsource
exp fn request_clipboard(self window: &var Window)
Asks for the clipboard's text, which an Event::Clipboard gives.
fn open_filessource
exp fn open_files(self window: &var Window, dialog: FileDialog) -> u64
Shows a dialog choosing files to open; an Event::FilesChosen with the returned request gives them.
fn save_filesource
exp fn save_file(self window: &var Window, dialog: FileDialog) -> u64
Shows a dialog choosing where to save, dialog.name proposed; an
Event::FilesChosen with the returned request gives the file, which
save_bytes writes.
fn save_bytessource
exp fn save_bytes(self window: &var Window, file: &ChosenFile, bytes: &[u8]) -> bool
Writes the bytes into a file save_file gave: at its path on the
desktop, and on the web through the page (where the browser lets a
page write a chosen file) or as a download; whether it was written or
given to the page.
fn nowsource
exp fn now(self window: &Window) -> Duration
The time on the window's clock: monotonic, from when the window opened; a headless window's stands still but as its script moves it.
fn wake_atsource
exp fn wake_at(self window: &var Window, at: Option<Duration>)
Asks for an Event::Timer at the time on the window's clock, or after; each call replaces the time the last asked for, and None asks for none.
fn set_historysource
exp fn set_history(self window: &var Window, depth: u64, path: String)
Keeps the page's history in step with where the program is: a deeper entry goes into the history after the one shown (the browser's Back then giving Event::Navigated), a shallower one goes back to it and a new path replaces the shown entry's; an empty path leaves the address as it is. Only a page has a history: elsewhere this does nothing.
fn set_languagesource
exp fn set_language(self window: &var Window, tag: &[u8], right_to_left: bool)
Tells screen readers the language the window's content is in, a BCP
47 tag, and whether it reads right to left: UI Automation's Culture,
AT-SPI's locale, the accessibility layer's lang and dir on the
web, the view's layout direction on macOS.
fn languagesource
exp fn language(self window: &Window) -> &[u8]
The language set_language gave, "en" until then.
fn right_to_leftsource
exp fn right_to_left(self window: &Window) -> bool
fn reduced_motionsource
exp fn reduced_motion(self window: &Window) -> bool
Whether the system asks programs for less motion: GNOME's animations
off or KDE's at no length through the settings portal, Windows'
"Animation effects" off, macOS's "Reduce motion", a page's
prefers-reduced-motion; never in a headless window but as its script
says. Event::ReducedMotion tells a change.
fn start_pathsource
exp fn start_path(self window: &Window) -> &[u8]
The path the page was opened or reloaded at, after the address's #;
empty elsewhere.
fn wakersource
exp fn waker(self window: &Window) -> Waker
What wakes the window's loop from another task.
fn wakesource
exp fn wake(self waker: &Waker)
Wakes the window's loop, which gives its handler an Event::Woken.
fn sizesource
exp fn size(self window: &Window) -> Size
The size in physical pixels.
fn scalesource
exp fn scale(self window: &Window) -> f32
Physical pixels per logical pixel.
fn focusedsource
exp fn focused(self window: &Window) -> bool
Whether the window has the keyboard.
fn titlesource
exp fn title(self window: &Window) -> &[u8]
The title the window shows.
fn set_titlesource
exp fn set_title(self window: &var Window, title: &[u8])
Changes the title the window shows.
fn request_redrawsource
exp fn request_redraw(self window: &var Window)
Asks for a Redraw event when the display is next ready for a frame: called while handling Redraw, it draws one frame after another.
fn closesource
exp fn close(self window: &var Window)
Closes the window, which ends run once the handler returns.
fn set_text_inputsource
exp fn set_text_input(self window: &var Window, area: Option<Area>)
Turns the platform's input method on while a text field has the keyboard, giving the caret's area, which the input method's own windows keep clear of: compositions then come as Preedit events. ::None turns it off, as it starts. Text typed comes as Text events either way.
fn set_secret_inputsource
exp fn set_secret_input(self window: &var Window, secret: bool)
Tells the input method whether the text typed is a password, hidden as it is typed: then nothing composes and nothing typed is remembered or suggested (Wayland's content purpose, no input context on Windows, a password input on the web, secure input on macOS).
fn presentsource
exp fn present(self window: &var Window, pixels: &[u32], size: Size)
Shows the pixels, size of them row by row from the top left, each
0xRRGGBB (the top byte unused): software drawing, for a window no GPU
surface draws into. The window shows them scaled to its size when the
two differ.
fn targetsource
exp fn target(self window: &Window) -> Target
The native objects a GPU surface draws into.
fn surface_presentedsource
exp fn surface_presented(self window: &var Window)
Tells the window a GPU surface presented a frame into it, in place of
present, for pkg::alloy::gpu: the window then neither draws its own
frame nor waits for the display before the next Redraw, which the
surface's presenting paces.
fn runsource
exp fn run<S>(config: &WindowConfig, state: S, handler: |=| (&var S, &var Window, &Event)) -> i32
Opens the window and runs the platform's event loop, calling the
handler with the state and each event until the window closes; gives
the exit status for main, 1 when no window can open (the reason
printed). In a browser, whose event loop goes on after main returns,
it returns 0 at once, leaving the window running.