tecs.platform.window
Host-neutral state and commands for one application window.
Nupp owns the requested configuration and the last state observed from the host. Rust owns the winit window. Game-facing setters enqueue typed commands; they do not update getters optimistically because a compositor may reject or defer a request. The host drains commands, applies them, and reports a complete state snapshot or a failure for the originating serial.
Module contents
Constructors
| Constructor | Description |
|---|---|
newWindow | Creates a detached window contract without opening an OS window. |
Types
| Type | Kind | Description |
|---|---|---|
Command | type | One command drained by the Rust winit adapter. |
CommandFailure | record | A host rejection associated with one command serial. |
CreateOptions | record | The validated creation request read by the Rust host. |
CursorGrab | type | A pointer confinement mode understood by winit. |
HostState | record | A complete host observation applied atomically to a window. |
Options | type | Optional settings copied when the application is constructed. |
RequestRedrawCommand | record | A request for a redraw callback on the next suitable host turn. |
SetCursorGrabCommand | record | A request to change pointer confinement. |
SetCursorVisibleCommand | record | A request to show or hide the pointer. |
SetFullscreenCommand | record | A request to enter or leave borderless desktop fullscreen. |
SetPositionCommand | record | A request to move the top-left client position. |
SetResizableCommand | record | A request to enable or disable edge resizing. |
SetSizeCommand | record | A request to change the logical client size. |
SetTitleCommand | record | A request to change the desktop title. |
SetVisibleCommand | record | A request to map or unmap the window. |
Window | record | The game-facing handle for one Rust-owned window. |
Functions
| Function | Kind | Description |
|---|---|---|
applyState | function | Replaces observed state after the host applies commands or reads the OS. |
attach | function | Attaches the OS window and atomically installs its initial observed state. |
detach | function | Detaches an OS window after host teardown. |
drainCommands | function | Removes the current pending command batch for the host to process. |
handleEvent | function | Folds a translated window event before game observers receive it. |
reportFailure | function | Records a non-empty operational failure for one command. |
takeFailures | function | Removes the current command failures for game-side diagnostics. |
Constructors#
newWindowconstructor#
Creates a detached window contract without opening an OS window.
Arguments
| Name | Type | Description |
|---|---|---|
options | Options? | the copied and validated creation options |
Returns
| Type | Description |
|---|---|
Window | a window ready for the Rust host to attach |
Types#
Commandtype#
type Command = SetTitleCommand
| SetSizeCommand
| SetPositionCommand
| SetVisibleCommand
| SetResizableCommand
| SetFullscreenCommand
| SetCursorVisibleCommand
| SetCursorGrabCommand
| RequestRedrawCommandOne command drained by the Rust winit adapter.
CommandFailurerecord#
A host rejection associated with one command serial.
Fields
serial#
serial: integerreason#
reason: stringCreateOptionsrecord#
record CreateOptions
title: string
width: integer
height: integer
resizable: boolean
fullscreen: boolean
decorations: boolean
visible: boolean
alwaysOnTop: boolean
transparent: boolean
x: integer?
y: integer?
minWidth: integer?
minHeight: integer?
maxWidth: integer?
maxHeight: integer?
endThe validated creation request read by the Rust host.
Fields
title#
title: stringwidth#
width: integerheight#
height: integerresizable#
resizable: booleanfullscreen#
fullscreen: booleandecorations#
decorations: booleanvisible#
visible: booleanalwaysOnTop#
alwaysOnTop: booleantransparent#
transparent: booleanx#
x: integer?y#
y: integer?minWidth#
minWidth: integer?minHeight#
minHeight: integer?maxWidth#
maxWidth: integer?maxHeight#
maxHeight: integer?CursorGrabtype#
type CursorGrab = "none" | "confined" | "locked"A pointer confinement mode understood by winit.
HostStaterecord#
record HostState
id: integer
title: string
width: integer
height: integer
pixelWidth: integer
pixelHeight: integer
scaleFactor: number
x: integer
y: integer
focused: boolean
visible: boolean
minimized: boolean
maximized: boolean
fullscreen: boolean
occluded: boolean
resizable: boolean
cursorVisible: boolean
cursorGrab: CursorGrab
endA complete host observation applied atomically to a window.
Fields
id#
id: integertitle#
title: stringwidth#
width: integerheight#
height: integerpixelWidth#
pixelWidth: integerpixelHeight#
pixelHeight: integerscaleFactor#
scaleFactor: numberx#
x: integery#
y: integerfocused#
focused: booleanvisible#
visible: booleanminimized#
minimized: booleanmaximized#
maximized: booleanfullscreen#
fullscreen: booleanoccluded#
occluded: booleanresizable#
resizable: booleancursorVisible#
cursorVisible: booleancursorGrab#
cursorGrab: CursorGrabOptionstype#
type Options = {
title: string?,
width: integer?,
height: integer?,
resizable: boolean?,
fullscreen: boolean?,
borderless: boolean?,
hidden: boolean?,
alwaysOnTop: boolean?,
transparent: boolean?,
x: integer?,
y: integer?,
minWidth: integer?,
minHeight: integer?,
maxWidth: integer?,
maxHeight: integer?
}Optional settings copied when the application is constructed.
RequestRedrawCommandrecord#
A request for a redraw callback on the next suitable host turn.
Fields
kind#
kind: "requestRedraw"serial#
serial: integerSetCursorGrabCommandrecord#
record SetCursorGrabCommand
kind: "setCursorGrab"
serial: integer
mode: CursorGrab
endA request to change pointer confinement.
Fields
kind#
kind: "setCursorGrab"serial#
serial: integermode#
mode: CursorGrabSetCursorVisibleCommandrecord#
A request to show or hide the pointer.
Fields
kind#
kind: "setCursorVisible"serial#
serial: integervisible#
visible: booleanSetFullscreenCommandrecord#
record SetFullscreenCommand
kind: "setFullscreen"
serial: integer
fullscreen: boolean
endA request to enter or leave borderless desktop fullscreen.
Fields
kind#
kind: "setFullscreen"serial#
serial: integerfullscreen#
fullscreen: booleanSetPositionCommandrecord#
A request to move the top-left client position.
Fields
kind#
kind: "setPosition"serial#
serial: integerx#
x: integery#
y: integerSetResizableCommandrecord#
A request to enable or disable edge resizing.
Fields
kind#
kind: "setResizable"serial#
serial: integerresizable#
resizable: booleanSetSizeCommandrecord#
A request to change the logical client size.
Fields
kind#
kind: "setSize"serial#
serial: integerwidth#
width: integerheight#
height: integerSetTitleCommandrecord#
A request to change the desktop title.
Fields
kind#
kind: "setTitle"serial#
serial: integertitle#
title: stringSetVisibleCommandrecord#
A request to map or unmap the window.
Fields
kind#
kind: "setVisible"serial#
serial: integervisible#
visible: booleanWindowrecord#
record Window
creationOptions: function(borrows self: Window): CreateOptions
isAttached: function(borrows self: Window): boolean
id: function(borrows self: Window): integer
title: function(borrows self: Window): string
getSize: function(borrows self: Window): (integer, integer)
getPixelSize: function(borrows self: Window): (integer, integer)
scaleFactor: function(borrows self: Window): number
position: function(borrows self: Window): (integer, integer)
hasFocus: function(borrows self: Window): boolean
isVisible: function(borrows self: Window): boolean
isMinimized: function(borrows self: Window): boolean
isMaximized: function(borrows self: Window): boolean
isFullscreen: function(borrows self: Window): boolean
isOccluded: function(borrows self: Window): boolean
isResizable: function(borrows self: Window): boolean
isCursorVisible: function(borrows self: Window): boolean
cursorGrab: function(borrows self: Window): CursorGrab
setTitle: function(exclusive self: Window, title: string): integer
setSize: function(exclusive self: Window, width: integer, height: integer): integer
setPosition: function(exclusive self: Window, x: integer, y: integer): integer
setVisible: function(exclusive self: Window, visible: boolean): integer
setResizable: function(exclusive self: Window, resizable: boolean): integer
setFullscreen: function(exclusive self: Window, fullscreen: boolean): integer
setCursorVisible: function(exclusive self: Window, visible: boolean): integer
setCursorGrab: function(exclusive self: Window, mode: CursorGrab): integer
requestRedraw: function(exclusive self: Window): integer
endThe game-facing handle for one Rust-owned window.
Methods
creationOptions#
creationOptions: function(borrows self: Window): CreateOptionsReturns a detached copy of the validated creation request.
Arguments
| Name | Type | Description |
|---|---|---|
borrows self | Window |
Returns
| Type | Description |
|---|---|
CreateOptions |
isAttached#
isAttached: function(borrows self: Window): booleanReports whether the Rust host has attached an OS window.
Arguments
| Name | Type | Description |
|---|---|---|
borrows self | Window |
Returns
| Type | Description |
|---|---|
boolean |
id#
id: function(borrows self: Window): integerReturns the application-local host window id, or zero before attachment.
Arguments
| Name | Type | Description |
|---|---|---|
borrows self | Window |
Returns
| Type | Description |
|---|---|
integer |
title#
title: function(borrows self: Window): stringReturns the last title acknowledged by the host.
Arguments
| Name | Type | Description |
|---|---|---|
borrows self | Window |
Returns
| Type | Description |
|---|---|
string |
getSize#
getSize: function(borrows self: Window): (integer, integer)Returns the last logical client size observed from the host.
Arguments
| Name | Type | Description |
|---|---|---|
borrows self | Window |
Returns
| Type | Description |
|---|---|
integer | |
integer |
getPixelSize#
getPixelSize: function(borrows self: Window): (integer, integer)Returns the last physical drawable size observed from the host.
Arguments
| Name | Type | Description |
|---|---|---|
borrows self | Window |
Returns
| Type | Description |
|---|---|
integer | |
integer |
scaleFactor#
scaleFactor: function(borrows self: Window): numberReturns the current physical-pixels-per-logical-unit ratio.
Arguments
| Name | Type | Description |
|---|---|---|
borrows self | Window |
Returns
| Type | Description |
|---|---|
number |
position#
position: function(borrows self: Window): (integer, integer)Returns the last desktop position observed from the host.
Arguments
| Name | Type | Description |
|---|---|---|
borrows self | Window |
Returns
| Type | Description |
|---|---|
integer | |
integer |
hasFocus#
hasFocus: function(borrows self: Window): booleanArguments
| Name | Type | Description |
|---|---|---|
borrows self | Window |
Returns
| Type | Description |
|---|---|
boolean |
isVisible#
isVisible: function(borrows self: Window): booleanArguments
| Name | Type | Description |
|---|---|---|
borrows self | Window |
Returns
| Type | Description |
|---|---|
boolean |
isMinimized#
isMinimized: function(borrows self: Window): booleanArguments
| Name | Type | Description |
|---|---|---|
borrows self | Window |
Returns
| Type | Description |
|---|---|
boolean |
isMaximized#
isMaximized: function(borrows self: Window): booleanArguments
| Name | Type | Description |
|---|---|---|
borrows self | Window |
Returns
| Type | Description |
|---|---|
boolean |
isFullscreen#
isFullscreen: function(borrows self: Window): booleanArguments
| Name | Type | Description |
|---|---|---|
borrows self | Window |
Returns
| Type | Description |
|---|---|
boolean |
isOccluded#
isOccluded: function(borrows self: Window): booleanArguments
| Name | Type | Description |
|---|---|---|
borrows self | Window |
Returns
| Type | Description |
|---|---|
boolean |
isResizable#
isResizable: function(borrows self: Window): booleanArguments
| Name | Type | Description |
|---|---|---|
borrows self | Window |
Returns
| Type | Description |
|---|---|
boolean |
isCursorVisible#
isCursorVisible: function(borrows self: Window): booleanArguments
| Name | Type | Description |
|---|---|---|
borrows self | Window |
Returns
| Type | Description |
|---|---|
boolean |
cursorGrab#
cursorGrab: function(borrows self: Window): CursorGrabArguments
| Name | Type | Description |
|---|---|---|
borrows self | Window |
Returns
| Type | Description |
|---|---|
CursorGrab |
setTitle#
setTitle: function(exclusive self: Window, title: string): integerArguments
| Name | Type | Description |
|---|---|---|
exclusive self | Window | |
title | string |
Returns
| Type | Description |
|---|---|
integer |
setSize#
setSize: function(exclusive self: Window, width: integer, height: integer): integerArguments
| Name | Type | Description |
|---|---|---|
exclusive self | Window | |
width | integer | |
height | integer |
Returns
| Type | Description |
|---|---|
integer |
setPosition#
setPosition: function(exclusive self: Window, x: integer, y: integer): integerArguments
| Name | Type | Description |
|---|---|---|
exclusive self | Window | |
x | integer | |
y | integer |
Returns
| Type | Description |
|---|---|
integer |
setVisible#
setVisible: function(exclusive self: Window, visible: boolean): integerArguments
| Name | Type | Description |
|---|---|---|
exclusive self | Window | |
visible | boolean |
Returns
| Type | Description |
|---|---|
integer |
setResizable#
setResizable: function(exclusive self: Window, resizable: boolean): integerArguments
| Name | Type | Description |
|---|---|---|
exclusive self | Window | |
resizable | boolean |
Returns
| Type | Description |
|---|---|
integer |
setFullscreen#
setFullscreen: function(exclusive self: Window, fullscreen: boolean): integerArguments
| Name | Type | Description |
|---|---|---|
exclusive self | Window | |
fullscreen | boolean |
Returns
| Type | Description |
|---|---|
integer |
setCursorVisible#
setCursorVisible: function(exclusive self: Window, visible: boolean): integerArguments
| Name | Type | Description |
|---|---|---|
exclusive self | Window | |
visible | boolean |
Returns
| Type | Description |
|---|---|
integer |
setCursorGrab#
setCursorGrab: function(exclusive self: Window, mode: CursorGrab): integerArguments
| Name | Type | Description |
|---|---|---|
exclusive self | Window | |
mode | CursorGrab |
Returns
| Type | Description |
|---|---|
integer |
Functions#
applyStatefunction#
Replaces observed state after the host applies commands or reads the OS.
Arguments
| Name | Type | Description |
|---|---|---|
exclusive window | Window | the attached window contract |
state | HostState | the complete new state |
Returns
| Type | Description |
|---|---|
nil |
attachfunction#
Attaches the OS window and atomically installs its initial observed state.
Arguments
| Name | Type | Description |
|---|---|---|
exclusive window | Window | the contract the host created the OS window for |
state | HostState | the complete initial state |
Returns
| Type | Description |
|---|---|
nil |
Raises
when already attached or when the state is invalid
detachfunction#
function detach(exclusive window: Window): nilDetaches an OS window after host teardown.
Arguments
| Name | Type | Description |
|---|---|---|
exclusive window | Window | the contract to detach |
Returns
| Type | Description |
|---|---|
nil |
drainCommandsfunction#
Removes the current pending command batch for the host to process.
Arguments
| Name | Type | Description |
|---|---|---|
exclusive window | Window | the window whose requests the host is draining |
Returns
| Type | Description |
|---|---|
{Command} | the ordered command batch, which the caller owns |
handleEventfunction#
function handleEvent(exclusive window: Window, event: platformevents.Event): nilFolds a translated window event before game observers receive it.
Arguments
| Name | Type | Description |
|---|---|---|
exclusive window | Window | the window contract receiving the event |
event | platformevents.Event | the ordered platform event |
Returns
| Type | Description |
|---|---|
nil |
reportFailurefunction#
function reportFailure(exclusive window: Window, serial: integer, reason: string): nilRecords a non-empty operational failure for one command.
Arguments
| Name | Type | Description |
|---|---|---|
exclusive window | Window | the originating window |
serial | integer | the rejected command serial |
reason | string | the host failure suitable for diagnostics |
Returns
| Type | Description |
|---|---|
nil |
takeFailuresfunction#
function takeFailures(exclusive window: Window): {CommandFailure}Removes the current command failures for game-side diagnostics.
Arguments
| Name | Type | Description |
|---|---|---|
exclusive window | Window | the window whose failures are consumed |
Returns
| Type | Description |
|---|---|
{CommandFailure} | the ordered failure batch, which the caller owns |