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

ConstructorDescription
newWindowCreates a detached window contract without opening an OS window.

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.
reportFailurefunctionRecords a non-empty operational failure for one command.
takeFailuresfunctionRemoves the current command failures for game-side diagnostics.

Constructors#

newWindowconstructor#

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

Types#

Commandtype#

One command drained by the Rust winit adapter.

CommandFailurerecord#

record CommandFailure
    serial: integer
    reason: string
end

A host rejection associated with one command serial.

Fields

serial#
serial: integer
reason#
reason: string

CreateOptionsrecord#

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?
end

The validated creation request read by the Rust host.

Fields

title#
title: string
width#
width: integer
height#
height: integer
resizable#
resizable: boolean
fullscreen#
fullscreen: boolean
decorations#
decorations: boolean
visible#
visible: boolean
alwaysOnTop#
alwaysOnTop: boolean
transparent#
transparent: boolean
x#
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
end

A complete host observation applied atomically to a window.

Fields

id#
id: integer
title#
title: string
width#
width: integer
height#
height: integer
pixelWidth#
pixelWidth: integer
pixelHeight#
pixelHeight: integer
scaleFactor#
scaleFactor: number
x#
x: integer
y#
y: integer
focused#
focused: boolean
visible#
visible: boolean
minimized#
minimized: boolean
maximized#
maximized: boolean
fullscreen#
fullscreen: boolean
occluded#
occluded: boolean
resizable#
resizable: boolean
cursorVisible#
cursorVisible: boolean
cursorGrab#
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
    kind: "requestRedraw"
    serial: integer
end

A request for a redraw callback on the next suitable host turn.

Fields

kind#
kind: "requestRedraw"
serial#
serial: integer

SetCursorGrabCommandrecord#

record SetCursorGrabCommand
    kind: "setCursorGrab"
    serial: integer
    mode: CursorGrab
end

A request to change pointer confinement.

Fields

kind#
kind: "setCursorGrab"
serial#
serial: integer
mode#

SetCursorVisibleCommandrecord#

record SetCursorVisibleCommand
    kind: "setCursorVisible"
    serial: integer
    visible: boolean
end

A request to show or hide the pointer.

Fields

kind#
kind: "setCursorVisible"
serial#
serial: integer
visible#
visible: boolean

SetFullscreenCommandrecord#

record SetFullscreenCommand
    kind: "setFullscreen"
    serial: integer
    fullscreen: boolean
end

A request to enter or leave borderless desktop fullscreen.

Fields

kind#
kind: "setFullscreen"
serial#
serial: integer
fullscreen#
fullscreen: boolean

SetPositionCommandrecord#

record SetPositionCommand
    kind: "setPosition"
    serial: integer
    x: integer
    y: integer
end

A request to move the top-left client position.

Fields

kind#
kind: "setPosition"
serial#
serial: integer
x#
x: integer
y#
y: integer

SetResizableCommandrecord#

record SetResizableCommand
    kind: "setResizable"
    serial: integer
    resizable: boolean
end

A request to enable or disable edge resizing.

Fields

kind#
kind: "setResizable"
serial#
serial: integer
resizable#
resizable: boolean

SetSizeCommandrecord#

record SetSizeCommand
    kind: "setSize"
    serial: integer
    width: integer
    height: integer
end

A request to change the logical client size.

Fields

kind#
kind: "setSize"
serial#
serial: integer
width#
width: integer
height#
height: integer

SetTitleCommandrecord#

record SetTitleCommand
    kind: "setTitle"
    serial: integer
    title: string
end

A request to change the desktop title.

Fields

kind#
kind: "setTitle"
serial#
serial: integer
title#
title: string

SetVisibleCommandrecord#

record SetVisibleCommand
    kind: "setVisible"
    serial: integer
    visible: boolean
end

A request to map or unmap the window.

Fields

kind#
kind: "setVisible"
serial#
serial: integer
visible#
visible: boolean

Windowrecord#

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
end

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

Methods

creationOptions#
creationOptions: function(borrows self: Window): CreateOptions

Returns a detached copy of the validated creation request.

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

Reports whether the Rust host has attached an OS window.

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

Returns the application-local host window id, or zero before attachment.

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

Returns the last title acknowledged by the host.

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

Returns the last logical client size observed from the host.

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

Returns the last physical drawable size observed from the host.

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

Returns the current physical-pixels-per-logical-unit ratio.

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

Returns the last desktop position observed from the host.

Arguments
NameTypeDescription
borrows selfWindow
Returns
TypeDescription
integer
integer
hasFocus#
hasFocus: function(borrows self: Window): boolean
Arguments
NameTypeDescription
borrows selfWindow
Returns
TypeDescription
boolean
isVisible#
isVisible: function(borrows self: Window): boolean
Arguments
NameTypeDescription
borrows selfWindow
Returns
TypeDescription
boolean
isMinimized#
isMinimized: function(borrows self: Window): boolean
Arguments
NameTypeDescription
borrows selfWindow
Returns
TypeDescription
boolean
isMaximized#
isMaximized: function(borrows self: Window): boolean
Arguments
NameTypeDescription
borrows selfWindow
Returns
TypeDescription
boolean
isFullscreen#
isFullscreen: function(borrows self: Window): boolean
Arguments
NameTypeDescription
borrows selfWindow
Returns
TypeDescription
boolean
isOccluded#
isOccluded: function(borrows self: Window): boolean
Arguments
NameTypeDescription
borrows selfWindow
Returns
TypeDescription
boolean
isResizable#
isResizable: function(borrows self: Window): boolean
Arguments
NameTypeDescription
borrows selfWindow
Returns
TypeDescription
boolean
isCursorVisible#
isCursorVisible: function(borrows self: Window): boolean
Arguments
NameTypeDescription
borrows selfWindow
Returns
TypeDescription
boolean
cursorGrab#
cursorGrab: function(borrows self: Window): CursorGrab
Arguments
NameTypeDescription
borrows selfWindow
Returns
TypeDescription
CursorGrab
setTitle#
setTitle: function(exclusive self: Window, title: string): integer
Arguments
NameTypeDescription
exclusive selfWindow
titlestring
Returns
TypeDescription
integer
setSize#
setSize: function(exclusive self: Window, width: integer, height: integer): integer
Arguments
NameTypeDescription
exclusive selfWindow
widthinteger
heightinteger
Returns
TypeDescription
integer
setPosition#
setPosition: function(exclusive self: Window, x: integer, y: integer): integer
Arguments
NameTypeDescription
exclusive selfWindow
xinteger
yinteger
Returns
TypeDescription
integer
setVisible#
setVisible: function(exclusive self: Window, visible: boolean): integer
Arguments
NameTypeDescription
exclusive selfWindow
visibleboolean
Returns
TypeDescription
integer
setResizable#
setResizable: function(exclusive self: Window, resizable: boolean): integer
Arguments
NameTypeDescription
exclusive selfWindow
resizableboolean
Returns
TypeDescription
integer
setFullscreen#
setFullscreen: function(exclusive self: Window, fullscreen: boolean): integer
Arguments
NameTypeDescription
exclusive selfWindow
fullscreenboolean
Returns
TypeDescription
integer
setCursorVisible#
setCursorVisible: function(exclusive self: Window, visible: boolean): integer
Arguments
NameTypeDescription
exclusive selfWindow
visibleboolean
Returns
TypeDescription
integer
setCursorGrab#
setCursorGrab: function(exclusive self: Window, mode: CursorGrab): integer
Arguments
NameTypeDescription
exclusive selfWindow
modeCursorGrab
Returns
TypeDescription
integer
requestRedraw#
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

  • 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

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