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. publish_viewport copies the live size and device-pixel ratio here from the main world’s Viewport, which every window backend and the headless runner keep current; 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.

Functions§

dpr
Current device-pixel ratio / scale factor (window.dpr).
publish_viewport
Copy the main world’s Viewport into the cache whenever it changes, so window.size() and window.dpr() read what the app is running at. Registered by App::new at the start of each tick, ahead of every script handler.
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.