Skip to main content

Module session

Module session 

Source
Expand description

Whether anything on screen can be seen at all: on macOS, the displays asleep, the screen locked, or the user’s session switched out.

AppKit reports a window not visible when another window covers it, when it is minimised, and when it was never shown. A window already showing stays visible to it while the displays sleep or the screen is locked, so wgpu goes on acquiring its frames and the window goes on drawing them for nobody. A SessionWatch hears those changes from the system instead: NSWorkspace’s screens-did-sleep and session-did-resign-active notifications and their opposites, and the distributed com.apple.screenIsLocked and com.apple.screenIsUnlocked, which Apple does not document but macOS has posted for many releases.

Each of the three reasons is set and cleared by its own notifications. A clearing notification that never came would leave every window drawing nothing, so SessionWatch::recheck reads what the system reports and clears a reason it no longer does. It never sets one: a reading that is wrong can only mean frames drawn for nobody, which is what happened before there was a watch. For the same reason the watch starts with no reason set, even in a session already locked when it starts.

There is no watch elsewhere. A Wayland compositor stops asking a surface it does not show for frames, which already holds a window’s redraws.

Structs§

SessionWatch
Watches whether anything on screen can be seen; see the module. Dropping it stops the watch.