Expand description
sk-tree — the retained node tree that Vue’s custom renderer mutates through __sk_* host
functions, and the per-frame lowering of that tree into gpui elements.
JS holds dense u32 node ids (0 = none); tags, style keys and event names are interned once via
__sk_intern so the hot path carries no strings. Structural ops apply synchronously; insert is
also move (implicit detach), remove destroys the whole subtree. Mutations mark the tree dirty
and the frame pump notifies the root view after the JS wave.
Re-exports§
pub use windows::WinKey;
Modules§
- devtools
- The read/drive surface
sk-devtoolssits on: selector queries against the REAL cascade matcher, node dumps off the retained tree, and synthesized input through the ordinary dispatch path. - iframe
<iframe>: a document in a platform webview, drawn into the element’s box.- log
- A bounded in-process log ring so the devtools
logscommand can read back what the host printed. Off unlessenableis called, sorecordis one relaxed atomic load. Output is teed here, not moved: the terminal keeps showing exactly what it did. The ring is thread-local because every recorder lives on the VM/gpui main thread. - perf
- Phase counters for the
SK_PERFprobe: the restyle and build phases that run deep insidesk-tree, accumulated into a one-second window thatsk-appdrains next to its own frame report. With the probe off a phase costs one relaxed atomic load. - windows
- Per-window state: one process, one
JsRuntimeand oneTree, but N gpui windows each painting one node of it. State the windows disagree about (focus, bounds, drag regions,@media) lives in oneWindowStatepergpui::WindowId; single-slot thread-locals would alias across windows. “Here” is passed, never guessed.
Structs§
- Event
Payload - The numeric payload a native input event carries into JS. Mouse: a=x b=y c=button, d=modifier
bits | click count << 4. Wheel: a=deltaX b=deltaY. Input:
key= the new value. Scroll: a=scrollLeft b=scrollTop. Modifier bits: 1 ctrl, 2 shift, 4 alt, 8 meta.
Enums§
Constants§
- EVENT_
NAMES - Every host event code with the name JS knows it by; devtools lists from here.
- EV_
AUXCLICK - Middle or right button pressed and released over one element; the target is the nearest common ancestor.
- EV_
BEFOREINPUT - Before each edit, cancelable (except the IME’s): a cancelled one makes no edit and no
input. - EV_BLUR
- EV_
CANPLAY - EV_
CANPLAYTHROUGH - EV_
CLICK - EV_
COMPLETE - EV_
COMPOSITIONEND - EV_
COMPOSITIONSTART - The IME composition’s stages (CompositionEvents,
dataas above): start, each pre-edit, and the end, which follows the commit’sinput. - EV_
COMPOSITIONUPDATE - EV_
CONTEXTMENU - A MouseEvent; also from the Menu key / Shift+F10 at the focused element.
- EV_COPY
- EV_CUT
- EV_
DURATIONCHANGE - EV_
EMPTIED - EV_
ENDED - EV_
ENTERFRAME - EV_
ERROR - Carries
MediaError.codeinaand the advisory text inkey. - EV_
FOCUS - EV_
INPUT - EV_
KEYDOWN - EV_
KEYUP - EV_LOAD
a/b= naturalWidth/naturalHeight,key= thesrc. A failure isEV_ERRORwith the samekey.- EV_
LOADEDDATA - EV_
LOADEDMETADATA - EV_
LOADSTART - EV_
LOOPCOMPLETE - EV_
MESSAGE - An
<iframe>’s document posted to its parent (crate::iframe): at the iframe’s node,key={"o": origin, "d": wire}. The runtime fires it atwindow. - EV_
MOUSEDOWN - EV_
MOUSEENTER - Non-bubbling, per the UI Events spec: fires only on the element entered.
- EV_
MOUSELEAVE - EV_
MOUSEMOVE - EV_
MOUSEUP - EV_
PASTE - EV_
PAUSE - EV_PLAY
- EV_
PLAYING - EV_
POINTERCANCEL - The window lost activation mid-press: only the press’s
mousedowntarget hears it. - EV_
POINTERLOCKCHANGE - The document’s pointer lock changed (
a= the request it settles, 0: none) or a request failed (key= “Name: message”). Delivered at node 0; the runtime fires both atdocument. - EV_
POINTERLOCKERROR - EV_
RATECHANGE - EV_
SCROLL - EV_
SEEKED - EV_
SEEKING - EV_
TIMEUPDATE - Throttled to the spec’s 250 ms.
- EV_
VOLUMECHANGE - EV_
WAITING - EV_
WHEEL
Functions§
- animating
- asset_
base - asset_
store - bounds_
in - The rectangle one window painted this node at; a rectangle is meaningful only in its window’s client space, so a point query must name the window.
- build_
root - build_
subtree - Builds one node’s subtree as the root of a second window’s element tree, with the same
per-window bookkeeping as
build_rootand the root treatment (100% size,Overflow::Scroll,track_focus). - build_
view_ transition - What the window shows over the document while a transition runs: the old state frozen until the pseudo-elements exist, then those. It takes every pointer event.
- content_
key - control_
hitboxes - control_
hitboxes_ in - dev_
asset_ file - Resolves one explicitly mapped dev URL with the same normalization as image/font/video URLs and fetch. Unknown keys never escape the app root.
- dispatch_
event - Dispatches an input event into JS and runs its microtask checkpoint so Vue’s flush lands in the
same frame. Needs
Phase::Commitpublished;falsemeans a handler calledpreventDefault(). Under a gpui listener the checkpoint is owed and run after gpui’s dispatch (render::settle_owed_later), where anonMountedthat measures can lay out. - dispatch_
event_ with dispatch_eventwith an object for the event to carry, passed as the dispatcher’s eighth argument: a ClipboardEvent’sclipboardData(crate::clipboard).- effects_
changed - The app’s
--shadingeffects were replaced (gpui::reload_app_effects): sk-css resolves an effect’s name and arguments when a sheet compiles or an inline style parses, so recompile, re-parse inline--shadingand restyle. A renamed or removed effect then degrades as an unknown one does. - enable_
pick_ hitboxes - env
- The last
set_envvalue, the sourcematchMediaevaluates against (the primary window’s). - flush_
changes - flush_
changes_ kind - Like
flush_changes, but tells a wave a forced layout already drew from one that needs a draw. - flush_
pending_ mouse_ move - The one
mousemovea frame may deliver (UAs alignmousemoveto the frame clock and drop the rest). Also the per-move dedup: gpui runs bubble handlers topmost-first, so the first (innermost) claim wins; otherwise k nested listeners ran k dispatch walks per move. The frame’s hover resolves first somouseleave/mouseenterprecedemousemove. - forget_
window - Forgets everything a window held, because it has closed. Its atlas went with it, so tiles it
still owed are dropped: another window’s
drop_imagecould remove keys that window re-inserted. - frame_
tick - Per-frame work that needs a
Window; call once per frame from the pump, before the draw. Returnstruewhen the window must repaint. - in_
input_ dispatch - True while a gpui listener (or gpui’s own draw) has called into JS. The forced layout must not
draw then: gpui took the frame’s listeners out, and focus listeners run inside
Window::draw. - install
- lotties_
animating - match_
media - Evaluates one media query against [
env], as the cascade would.Erris the compile failure. - painted_
bounds_ in - painted_
drag_ region - painted_
drag_ region_ in - pointer_
lock_ intercept_ escape - Escape releases the lock before anything else hears the key, and nothing on the page does. Every other key press counts as a gesture.
- pointer_
lock_ navigated - The document went away: its requests are never answered.
- popped_
out - read_
app_ asset - The bytes of one of the app’s own files by URL path (
/games/pong/index.html): from the package, or off disk under the app root (or itspublic/) in a dev host. - root_
bounds - Where the app root was painted in the window’s client area, CSS px;
Nonebefore the first frame. Host-drawn chrome is excluded, as ininnerWidth. - root_
bounds_ in root_boundsfor one window: the source of a per-window@mediaviewport and aSkWindow’s@resizepayload.- set_
asset_ base - set_
asset_ store - Makes relative
srcs resolve out oflookupinstead of the disk; set once at boot, on the render thread, by a packaged exe. - set_
dev_ asset_ files - Replaces the dev manifest’s imported-file map, also visible to fetch’s background threads. Only canonical generated keys and absolute paths pass.
- set_env
- Publishes the window environment
@mediais evaluated against (viewport, colour scheme, reduced motion, DPI, display mode). Call every frame; a change dirties the tree and returnstrue. - set_
env_ for - set_
os_ chrome - set_
os_ chrome_ in - set_
page_ hidden - A paint-only frame is not presented while the page is hidden (
crate::live); the draw that shows the window again paints the newest one. - set_
popped_ out - Marks (or unmarks) a node as painted by another window. Returns
truewhen the flag moved. - set_
reduce_ motion - set_
repaint_ all - set_
sync_ layout - Installs the host’s “draw one frame now” callback (
sk-treecannot depend onsk-app). - sync_
layout - Folds pending changes and draws one frame so a layout read answers from real rectangles. Re-entrant calls are dropped; a no-op with no hook installed.
- update_
layout_ observers - video_
device_ changed - The renderer recreated its D3D11 device; rebuild every
<video>on the new one, keeping position and transport state. - videos_
playing - window_
control_ at - The caption button a click on
nodelands on, as the hit test resolves it: the nearest ancestor-or-self declaring--window-control, with the window painting it.Nonewhere the OS draws the caption. - window_
frame_ tick - Per-frame work a SECONDARY window does from its own
render(): its atlas resources and focus. The JS-facing half stays inframe_tick(one JS realm, once per frame group). - with_
tree - Runs
fwith the tree. Panics (caught byhost_fn!, poisons) if it is already borrowed, i.e. JS mutating during a draw walk.
Type Aliases§
- Asset
Lookup - A packaged app’s asset store: app-root-relative key → bytes (mapped in the exe for the process’s life).