Skip to main content

Module window_state

Module window_state 

Source
Expand description

Process-global window-state mirror for the window script namespace.

The OS window lives inside the winit event loop, not in the ECS, so the window.title() / window.size() / window.dpr() getters and the window.set_title / window.set_size setters cannot reach it through a &World. They read and write this small cache instead. The window backend publishes the live size and device-pixel ratio here on resize and scale-factor changes; the setters write the requested title / size, which the backend applies to the real window when one exists. Headless runs have no window, so a setter followed by its getter round-trips through the cache; the observable contract the tests assert.

Functionsยง

dpr
Current device-pixel ratio / scale factor (window.dpr).
set_dpr
Publish the live device-pixel ratio (window backend, on scale change).
set_size
Request a new window size in logical pixels (window.set_size).
set_title
Request a new window title (window.set_title).
size
Current window size in logical pixels (window.size).
title
Current window title.