1.6 KiB
| id | name | category | kind | tokens | sig | tip | order | ns | member |
|---|---|---|---|---|---|---|---|---|---|
| app-window_hide | App.window_hide | app | namespace-method | App.window_hide | App.window_hide() -> void | Take the game's window off the screen. | 3 | App | window_hide |
Takes the game's window off the screen without closing it: its GL context or Vulkan surface, its size and its contents are kept, and the program goes on running — a hidden window does not end the run. App.window_show brings it back. It is how a launcher steps aside while the game it started with Process.spawn runs.
Keep the frame loop going while hidden so the child can be polled, but there is nothing to see: skip the drawing, and throttle the loop yourself — a hidden window is not paced by the display, so an unthrottled loop spins. It does not touch the boot splash (App.splash_hide does). Safe to call when there is no window yet, and twice. Headless there is no window and the call lowers to nothing.
program Launcher {
state Child { game: int = -1 }
function play(c: mut Child) -> void {
c.game = Process.spawn(game_path(), new []string)
if c.game >= 0 { App.window_hide() }
}
handler Watch(c: mut Child) phase Update {
if c.game >= 0 and Process.poll(c.game) != -1 {
Process.free(c.game)
c.game = -1
App.window_show()
}
}
}
orderOut: on macOS; ShowWindow(SW_HIDE) on Windows, which also forgets any key held as the window went.