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

TypeKindDescription
CommandtypeOne command drained by the Rust winit adapter.
CommandFailurerecordA host rejection associated with one command serial.
CreateOptionsrecordThe validated creation request read by the Rust host.
CursorGrabtypeA pointer confinement mode understood by winit.
HostStaterecordA complete host observation applied atomically to a window.
OptionstypeOptional settings copied when the application is constructed.
RequestRedrawCommandrecordA request for a redraw callback on the next suitable host turn.
SetCursorGrabCommandrecordA request to change pointer confinement.
SetCursorVisibleCommandrecordA request to show or hide the pointer.
SetFullscreenCommandrecordA request to enter or leave borderless desktop fullscreen.
SetPositionCommandrecordA request to move the top-left client position.
SetResizableCommandrecordA request to enable or disable edge resizing.
SetSizeCommandrecordA request to change the logical client size.
SetTitleCommandrecordA request to change the desktop title.
SetVisibleCommandrecordA request to map or unmap the window.
WindowrecordThe game-facing handle for one Rust-owned window.

Functions

FunctionKindDescription
applyStatefunctionReplaces observed state after the host applies commands or reads the OS.
attachfunctionAttaches the OS window and atomically installs its initial observed state.
detachfunctionDetaches an OS window after host teardown.
drainCommandsfunctionRemoves the current pending command batch for the host to process.
handleEventfunctionFolds a translated window event before game observers receive it.
newWindowfunctionCreates a detached window contract without opening an OS window.
reportFailurefunctionRecords a non-empty operational failure for one command.
takeFailuresfunctionRemoves the current command failures for game-side diagnostics.

Types#

Commandtype#

One command drained by the Rust winit adapter.

CommandFailurerecord#

record CommandFailure ...

A host rejection associated with one command serial.

Members

NameKindDescription
serialfield
reasonfield

serialfield#

serial: integer

reasonfield#

reason: string

CreateOptionsrecord#

record CreateOptions ...

The validated creation request read by the Rust host.

Members

NameKindDescription
titlefield
widthfield
heightfield
resizablefield
fullscreenfield
decorationsfield
visiblefield
alwaysOnTopfield
transparentfield
xfield
yfield
minWidthfield
minHeightfield
maxWidthfield
maxHeightfield

titlefield#

title: string

widthfield#

width: integer

heightfield#

height: integer

resizablefield#

resizable: boolean

fullscreenfield#

fullscreen: boolean

decorationsfield#

decorations: boolean

visiblefield#

visible: boolean

alwaysOnTopfield#

alwaysOnTop: boolean

transparentfield#

transparent: boolean

xfield#

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

NameKindDescription
idfield
titlefield
widthfield
heightfield
pixelWidthfield
pixelHeightfield
scaleFactorfield
xfield
yfield
focusedfield
visiblefield
minimizedfield
maximizedfield
fullscreenfield
occludedfield
resizablefield
cursorVisiblefield
cursorGrabfield

idfield#

id: integer

titlefield#

title: string

widthfield#

width: integer

heightfield#

height: integer

pixelWidthfield#

pixelWidth: integer

pixelHeightfield#

pixelHeight: integer

scaleFactorfield#

scaleFactor: number

xfield#

x: integer

yfield#

y: integer

focusedfield#

focused: boolean

visiblefield#

visible: boolean

minimizedfield#

minimized: boolean

maximizedfield#

maximized: boolean

fullscreenfield#

fullscreen: boolean

occludedfield#

occluded: boolean

resizablefield#

resizable: boolean

cursorVisiblefield#

cursorVisible: boolean

cursorGrabfield#

cursorGrab: CursorGrab

Optionstype#

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.

Members

NameKindDescription
kindfield
serialfield

kindfield#

kind: "requestRedraw"

serialfield#

serial: integer

SetCursorGrabCommandrecord#

record SetCursorGrabCommand ...

A request to change pointer confinement.

Members

NameKindDescription
kindfield
serialfield
modefield

kindfield#

kind: "setCursorGrab"

serialfield#

serial: integer

modefield#

SetCursorVisibleCommandrecord#

record SetCursorVisibleCommand ...

A request to show or hide the pointer.

Members

NameKindDescription
kindfield
serialfield
visiblefield

kindfield#

kind: "setCursorVisible"

serialfield#

serial: integer

visiblefield#

visible: boolean

SetFullscreenCommandrecord#

record SetFullscreenCommand ...

A request to enter or leave borderless desktop fullscreen.

Members

NameKindDescription
kindfield
serialfield
fullscreenfield

kindfield#

kind: "setFullscreen"

serialfield#

serial: integer

fullscreenfield#

fullscreen: boolean

SetPositionCommandrecord#

record SetPositionCommand ...

A request to move the top-left client position.

Members

NameKindDescription
kindfield
serialfield
xfield
yfield

kindfield#

kind: "setPosition"

serialfield#

serial: integer

xfield#

x: integer

yfield#

y: integer

SetResizableCommandrecord#

record SetResizableCommand ...

A request to enable or disable edge resizing.

Members

NameKindDescription
kindfield
serialfield
resizablefield

kindfield#

kind: "setResizable"

serialfield#

serial: integer

resizablefield#

resizable: boolean

SetSizeCommandrecord#

record SetSizeCommand ...

A request to change the logical client size.

Members

NameKindDescription
kindfield
serialfield
widthfield
heightfield

kindfield#

kind: "setSize"

serialfield#

serial: integer

widthfield#

width: integer

heightfield#

height: integer

SetTitleCommandrecord#

record SetTitleCommand ...

A request to change the desktop title.

Members

NameKindDescription
kindfield
serialfield
titlefield

kindfield#

kind: "setTitle"

serialfield#

serial: integer

titlefield#

title: string

SetVisibleCommandrecord#

record SetVisibleCommand ...

A request to map or unmap the window.

Members

NameKindDescription
kindfield
serialfield
visiblefield

kindfield#

kind: "setVisible"

serialfield#

serial: integer

visiblefield#

visible: boolean

Windowrecord#

record Window ...

The game-facing handle for one Rust-owned window.

Members

NameKindDescription
createfield
statefield
attachedfield
nextSerialfield
pendingfield
failuresfield
creationOptionsmethod
isAttachedmethod
idmethod
titlemethod
getSizemethod
getPixelSizemethod
scaleFactormethod
positionmethod
hasFocusmethod
isVisiblemethod
isMinimizedmethod
isMaximizedmethod
isFullscreenmethod
isOccludedmethod
isResizablemethod
isCursorVisiblemethod
cursorGrabmethod
setTitlemethod
setSizemethod
setPositionmethod
setVisiblemethod
setResizablemethod
setFullscreenmethod
setCursorVisiblemethod
setCursorGrabmethod
requestRedrawmethod

createfield#

@private

statefield#

state: HostState
@private

attachedfield#

attached: boolean
@private

nextSerialfield#

nextSerial: integer
@private

pendingfield#

@private

failuresfield#

failures: {CommandFailure}
@private

creationOptionsmethod#

creationOptions: function(borrows self: Window): CreateOptions
Arguments
NameTypeDescription
borrows selfWindow
Returns
TypeDescription
CreateOptions

isAttachedmethod#

isAttached: function(borrows self: Window): boolean
Arguments
NameTypeDescription
borrows selfWindow
Returns
TypeDescription
boolean

idmethod#

id: function(borrows self: Window): integer
Arguments
NameTypeDescription
borrows selfWindow
Returns
TypeDescription
integer

titlemethod#

title: function(borrows self: Window): string
Arguments
NameTypeDescription
borrows selfWindow
Returns
TypeDescription
string

getSizemethod#

getSize: function(borrows self: Window): (integer, integer)
Arguments
NameTypeDescription
borrows selfWindow
Returns
TypeDescription
integer
integer

getPixelSizemethod#

getPixelSize: function(borrows self: Window): (integer, integer)
Arguments
NameTypeDescription
borrows selfWindow
Returns
TypeDescription
integer
integer

scaleFactormethod#

scaleFactor: function(borrows self: Window): number
Arguments
NameTypeDescription
borrows selfWindow
Returns
TypeDescription
number

positionmethod#

position: function(borrows self: Window): (integer, integer)
Arguments
NameTypeDescription
borrows selfWindow
Returns
TypeDescription
integer
integer

hasFocusmethod#

hasFocus: function(borrows self: Window): boolean
Arguments
NameTypeDescription
borrows selfWindow
Returns
TypeDescription
boolean

isVisiblemethod#

isVisible: function(borrows self: Window): boolean
Arguments
NameTypeDescription
borrows selfWindow
Returns
TypeDescription
boolean

isMinimizedmethod#

isMinimized: function(borrows self: Window): boolean
Arguments
NameTypeDescription
borrows selfWindow
Returns
TypeDescription
boolean

isMaximizedmethod#

isMaximized: function(borrows self: Window): boolean
Arguments
NameTypeDescription
borrows selfWindow
Returns
TypeDescription
boolean

isFullscreenmethod#

isFullscreen: function(borrows self: Window): boolean
Arguments
NameTypeDescription
borrows selfWindow
Returns
TypeDescription
boolean

isOccludedmethod#

isOccluded: function(borrows self: Window): boolean
Arguments
NameTypeDescription
borrows selfWindow
Returns
TypeDescription
boolean

isResizablemethod#

isResizable: function(borrows self: Window): boolean
Arguments
NameTypeDescription
borrows selfWindow
Returns
TypeDescription
boolean

isCursorVisiblemethod#

isCursorVisible: function(borrows self: Window): boolean
Arguments
NameTypeDescription
borrows selfWindow
Returns
TypeDescription
boolean

cursorGrabmethod#

cursorGrab: function(borrows self: Window): CursorGrab
Arguments
NameTypeDescription
borrows selfWindow
Returns
TypeDescription
CursorGrab

setTitlemethod#

setTitle: function(exclusive self: Window, title: string): integer
Arguments
NameTypeDescription
exclusive selfWindow
titlestring
Returns
TypeDescription
integer

setSizemethod#

setSize: function(exclusive self: Window, width: integer, height: integer): integer
Arguments
NameTypeDescription
exclusive selfWindow
widthinteger
heightinteger
Returns
TypeDescription
integer

setPositionmethod#

setPosition: function(exclusive self: Window, x: integer, y: integer): integer
Arguments
NameTypeDescription
exclusive selfWindow
xinteger
yinteger
Returns
TypeDescription
integer

setVisiblemethod#

setVisible: function(exclusive self: Window, visible: boolean): integer
Arguments
NameTypeDescription
exclusive selfWindow
visibleboolean
Returns
TypeDescription
integer

setResizablemethod#

setResizable: function(exclusive self: Window, resizable: boolean): integer
Arguments
NameTypeDescription
exclusive selfWindow
resizableboolean
Returns
TypeDescription
integer

setFullscreenmethod#

setFullscreen: function(exclusive self: Window, fullscreen: boolean): integer
Arguments
NameTypeDescription
exclusive selfWindow
fullscreenboolean
Returns
TypeDescription
integer

setCursorVisiblemethod#

setCursorVisible: function(exclusive self: Window, visible: boolean): integer
Arguments
NameTypeDescription
exclusive selfWindow
visibleboolean
Returns
TypeDescription
integer

setCursorGrabmethod#

setCursorGrab: function(exclusive self: Window, mode: CursorGrab): integer
Arguments
NameTypeDescription
exclusive selfWindow
modeCursorGrab
Returns
TypeDescription
integer

requestRedrawmethod#

requestRedraw: function(exclusive self: Window): integer
Arguments
NameTypeDescription
exclusive selfWindow
Returns
TypeDescription
integer

Functions#

applyStatefunction#

function applyState(exclusive window: Window, state: HostState): nil

Replaces observed state after the host applies commands or reads the OS.

Arguments

NameTypeDescription
exclusive windowWindow

the attached window contract

stateHostState

the complete new state

Returns

TypeDescription
nil

attachfunction#

function attach(exclusive window: Window, state: HostState): nil

Attaches the OS window and atomically installs its initial observed state.

Arguments

NameTypeDescription
exclusive windowWindow

the contract the host created the OS window for

stateHostState

the complete initial state

Returns

TypeDescription
nil

Raises

TypeCondition
string

when already attached or when the state is invalid

detachfunction#

function detach(exclusive window: Window): nil

Detaches an OS window after host teardown.

Arguments

NameTypeDescription
exclusive windowWindow

the contract to detach

Returns

TypeDescription
nil

drainCommandsfunction#

function drainCommands(exclusive window: Window): {Command}

Removes the current pending command batch for the host to process.

Arguments

NameTypeDescription
exclusive windowWindow

the window whose requests the host is draining

Returns

TypeDescription
{Command}

the ordered command batch, which the caller owns

handleEventfunction#

function handleEvent(exclusive window: Window, event: platformevents.Event): nil

Folds a translated window event before game observers receive it.

Arguments

NameTypeDescription
exclusive windowWindow

the window contract receiving the event

eventplatformevents.Event

the ordered platform event

Returns

TypeDescription
nil

newWindowfunction#

function newWindow(options: Options?): Window

Creates a detached window contract without opening an OS window.

Arguments

NameTypeDescription
optionsOptions?

the copied and validated creation options

Returns

TypeDescription
Window

a window ready for the Rust host to attach

reportFailurefunction#

function reportFailure(exclusive window: Window, serial: integer, reason: string): nil

Records a non-empty operational failure for one command.

Arguments

NameTypeDescription
exclusive windowWindow

the originating window

serialinteger

the rejected command serial

reasonstring

the host failure suitable for diagnostics

Returns

TypeDescription
nil

takeFailuresfunction#

function takeFailures(exclusive window: Window): {CommandFailure}

Removes the current command failures for game-side diagnostics.

Arguments

NameTypeDescription
exclusive windowWindow

the window whose failures are consumed

Returns

TypeDescription
{CommandFailure}

the ordered failure batch, which the caller owns