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
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. |
newWindow | function | Creates a detached window contract without opening an OS window. |
reportFailure | function | Records a non-empty operational failure for one command. |
takeFailures | function | Removes the current command failures for game-side diagnostics. |
Types#
Commandtype#
type Command = SetTitleCommand
| SetSizeCommand
| SetPositionCommand
| SetVisibleCommand
| SetResizableCommand
| SetFullscreenCommand
| SetCursorVisibleCommand
| SetCursorGrabCommand
| RequestRedrawCommandOne command drained by the Rust winit adapter.
CommandFailurerecord#
record CommandFailure ...A host rejection associated with one command serial.
serialfield#
serial: integerreasonfield#
reason: stringCreateOptionsrecord#
record CreateOptions ...The validated creation request read by the Rust host.
Members
| Name | Kind | Description |
|---|---|---|
title | field | |
width | field | |
height | field | |
resizable | field | |
fullscreen | field | |
decorations | field | |
visible | field | |
alwaysOnTop | field | |
transparent | field | |
x | field | |
y | field | |
minWidth | field | |
minHeight | field | |
maxWidth | field | |
maxHeight | field |
titlefield#
title: stringwidthfield#
width: integerheightfield#
height: integerresizablefield#
resizable: booleanfullscreenfield#
fullscreen: booleandecorationsfield#
decorations: booleanvisiblefield#
visible: booleanalwaysOnTopfield#
alwaysOnTop: booleantransparentfield#
transparent: booleanxfield#
x: integer?yfield#
y: integer?minWidthfield#
minWidth: integer?minHeightfield#
minHeight: integer?maxWidthfield#
maxWidth: integer?maxHeightfield#
maxHeight: integer?CursorGrabtype#
type CursorGrab = "none" | "confined" | "locked"A pointer confinement mode understood by winit.
HostStaterecord#
record HostState ...A complete host observation applied atomically to a window.
Members
| Name | Kind | Description |
|---|---|---|
id | field | |
title | field | |
width | field | |
height | field | |
pixelWidth | field | |
pixelHeight | field | |
scaleFactor | field | |
x | field | |
y | field | |
focused | field | |
visible | field | |
minimized | field | |
maximized | field | |
fullscreen | field | |
occluded | field | |
resizable | field | |
cursorVisible | field | |
cursorGrab | field |
idfield#
id: integertitlefield#
title: stringwidthfield#
width: integerheightfield#
height: integerpixelWidthfield#
pixelWidth: integerpixelHeightfield#
pixelHeight: integerscaleFactorfield#
scaleFactor: numberxfield#
x: integeryfield#
y: integerfocusedfield#
focused: booleanvisiblefield#
visible: booleanminimizedfield#
minimized: booleanmaximizedfield#
maximized: booleanfullscreenfield#
fullscreen: booleanoccludedfield#
occluded: booleanresizablefield#
resizable: booleancursorVisiblefield#
cursorVisible: booleancursorGrabfield#
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#
record RequestRedrawCommand ...A request for a redraw callback on the next suitable host turn.
kindfield#
kind: "requestRedraw"serialfield#
serial: integerSetCursorGrabCommandrecord#
record SetCursorGrabCommand ...A request to change pointer confinement.
kindfield#
kind: "setCursorGrab"serialfield#
serial: integermodefield#
mode: CursorGrabSetCursorVisibleCommandrecord#
record SetCursorVisibleCommand ...A request to show or hide the pointer.
kindfield#
kind: "setCursorVisible"serialfield#
serial: integervisiblefield#
visible: booleanSetFullscreenCommandrecord#
record SetFullscreenCommand ...A request to enter or leave borderless desktop fullscreen.
Members
| Name | Kind | Description |
|---|---|---|
kind | field | |
serial | field | |
fullscreen | field |
kindfield#
kind: "setFullscreen"serialfield#
serial: integerfullscreenfield#
fullscreen: booleanSetPositionCommandrecord#
record SetPositionCommand ...A request to move the top-left client position.
kindfield#
kind: "setPosition"serialfield#
serial: integerxfield#
x: integeryfield#
y: integerSetResizableCommandrecord#
record SetResizableCommand ...A request to enable or disable edge resizing.
kindfield#
kind: "setResizable"serialfield#
serial: integerresizablefield#
resizable: booleanSetSizeCommandrecord#
record SetSizeCommand ...A request to change the logical client size.
kindfield#
kind: "setSize"serialfield#
serial: integerwidthfield#
width: integerheightfield#
height: integerSetTitleCommandrecord#
record SetTitleCommand ...A request to change the desktop title.
kindfield#
kind: "setTitle"serialfield#
serial: integertitlefield#
title: stringSetVisibleCommandrecord#
record SetVisibleCommand ...A request to map or unmap the window.
kindfield#
kind: "setVisible"serialfield#
serial: integervisiblefield#
visible: booleanWindowrecord#
record Window ...The game-facing handle for one Rust-owned window.
Members
| Name | Kind | Description |
|---|---|---|
create | field | |
state | field | |
attached | field | |
nextSerial | field | |
pending | field | |
failures | field | |
creationOptions | method | |
isAttached | method | |
id | method | |
title | method | |
getSize | method | |
getPixelSize | method | |
scaleFactor | method | |
position | method | |
hasFocus | method | |
isVisible | method | |
isMinimized | method | |
isMaximized | method | |
isFullscreen | method | |
isOccluded | method | |
isResizable | method | |
isCursorVisible | method | |
cursorGrab | method | |
setTitle | method | |
setSize | method | |
setPosition | method | |
setVisible | method | |
setResizable | method | |
setFullscreen | method | |
setCursorVisible | method | |
setCursorGrab | method | |
requestRedraw | method |
creationOptionsmethod#
creationOptions: function(borrows self: Window): CreateOptionsArguments
| Name | Type | Description |
|---|---|---|
borrows self | Window |
Returns
| Type | Description |
|---|---|
CreateOptions |
isAttachedmethod#
isAttached: function(borrows self: Window): booleanArguments
| Name | Type | Description |
|---|---|---|
borrows self | Window |
Returns
| Type | Description |
|---|---|
boolean |
idmethod#
id: function(borrows self: Window): integerArguments
| Name | Type | Description |
|---|---|---|
borrows self | Window |
Returns
| Type | Description |
|---|---|
integer |
titlemethod#
title: function(borrows self: Window): stringArguments
| Name | Type | Description |
|---|---|---|
borrows self | Window |
Returns
| Type | Description |
|---|---|
string |
getSizemethod#
getSize: function(borrows self: Window): (integer, integer)Arguments
| Name | Type | Description |
|---|---|---|
borrows self | Window |
Returns
| Type | Description |
|---|---|
integer | |
integer |
getPixelSizemethod#
getPixelSize: function(borrows self: Window): (integer, integer)Arguments
| Name | Type | Description |
|---|---|---|
borrows self | Window |
Returns
| Type | Description |
|---|---|
integer | |
integer |
scaleFactormethod#
scaleFactor: function(borrows self: Window): numberArguments
| Name | Type | Description |
|---|---|---|
borrows self | Window |
Returns
| Type | Description |
|---|---|
number |
positionmethod#
position: function(borrows self: Window): (integer, integer)Arguments
| Name | Type | Description |
|---|---|---|
borrows self | Window |
Returns
| Type | Description |
|---|---|
integer | |
integer |
hasFocusmethod#
hasFocus: function(borrows self: Window): booleanArguments
| Name | Type | Description |
|---|---|---|
borrows self | Window |
Returns
| Type | Description |
|---|---|
boolean |
isVisiblemethod#
isVisible: function(borrows self: Window): booleanArguments
| Name | Type | Description |
|---|---|---|
borrows self | Window |
Returns
| Type | Description |
|---|---|
boolean |
isMinimizedmethod#
isMinimized: function(borrows self: Window): booleanArguments
| Name | Type | Description |
|---|---|---|
borrows self | Window |
Returns
| Type | Description |
|---|---|
boolean |
isMaximizedmethod#
isMaximized: function(borrows self: Window): booleanArguments
| Name | Type | Description |
|---|---|---|
borrows self | Window |
Returns
| Type | Description |
|---|---|
boolean |
isFullscreenmethod#
isFullscreen: function(borrows self: Window): booleanArguments
| Name | Type | Description |
|---|---|---|
borrows self | Window |
Returns
| Type | Description |
|---|---|
boolean |
isOccludedmethod#
isOccluded: function(borrows self: Window): booleanArguments
| Name | Type | Description |
|---|---|---|
borrows self | Window |
Returns
| Type | Description |
|---|---|
boolean |
isResizablemethod#
isResizable: function(borrows self: Window): booleanArguments
| Name | Type | Description |
|---|---|---|
borrows self | Window |
Returns
| Type | Description |
|---|---|
boolean |
isCursorVisiblemethod#
isCursorVisible: function(borrows self: Window): booleanArguments
| Name | Type | Description |
|---|---|---|
borrows self | Window |
Returns
| Type | Description |
|---|---|
boolean |
cursorGrabmethod#
cursorGrab: function(borrows self: Window): CursorGrabArguments
| Name | Type | Description |
|---|---|---|
borrows self | Window |
Returns
| Type | Description |
|---|---|
CursorGrab |
setTitlemethod#
setTitle: function(exclusive self: Window, title: string): integerArguments
| Name | Type | Description |
|---|---|---|
exclusive self | Window | |
title | string |
Returns
| Type | Description |
|---|---|
integer |
setSizemethod#
setSize: function(exclusive self: Window, width: integer, height: integer): integerArguments
| Name | Type | Description |
|---|---|---|
exclusive self | Window | |
width | integer | |
height | integer |
Returns
| Type | Description |
|---|---|
integer |
setPositionmethod#
setPosition: function(exclusive self: Window, x: integer, y: integer): integerArguments
| Name | Type | Description |
|---|---|---|
exclusive self | Window | |
x | integer | |
y | integer |
Returns
| Type | Description |
|---|---|
integer |
setVisiblemethod#
setVisible: function(exclusive self: Window, visible: boolean): integerArguments
| Name | Type | Description |
|---|---|---|
exclusive self | Window | |
visible | boolean |
Returns
| Type | Description |
|---|---|
integer |
setResizablemethod#
setResizable: function(exclusive self: Window, resizable: boolean): integerArguments
| Name | Type | Description |
|---|---|---|
exclusive self | Window | |
resizable | boolean |
Returns
| Type | Description |
|---|---|
integer |
setFullscreenmethod#
setFullscreen: function(exclusive self: Window, fullscreen: boolean): integerArguments
| Name | Type | Description |
|---|---|---|
exclusive self | Window | |
fullscreen | boolean |
Returns
| Type | Description |
|---|---|
integer |
setCursorVisiblemethod#
setCursorVisible: function(exclusive self: Window, visible: boolean): integerArguments
| Name | Type | Description |
|---|---|---|
exclusive self | Window | |
visible | boolean |
Returns
| Type | Description |
|---|---|
integer |
setCursorGrabmethod#
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
| Type | Condition |
|---|---|
string | 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 |
newWindowfunction#
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 |
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 |