On this page
tecs.platform.window
Windows
tecs.platform.window creates OS windows and reads the displays around them. Application creates the usual game window as app.window. Tools and tests that call newWindow directly must call destroy when they finish.
local window <const> = tecs.platform.window.newWindow({
title = "Starfarer",
width = 1600,
height = 900,
hidden = true,
})
window:center()
window:show()Screen coordinates and pixels
Window layout and pointer input use screen coordinates. Render targets use pixels. A high-density display may put several pixels behind one screen coordinate.
local width <const>, height <const> = window:getSize()
local pixelWidth <const>, pixelHeight <const> = window:getPixelSize()
local density <const> = window:pixelDensity()
assert(pixelWidth == width * density)
assert(pixelHeight == height * density)displayScale reports the desktop's preferred scale for text and interface metrics. It does not convert between the two sizes.
Compositor changes
Size, position and fullscreen setters may return before the compositor applies the request. Most games consume the corresponding event later. Call sync only before an immediate readback.
window:setSize(1280, 720)
if window:sync() then
local width <const>, height <const> = window:getSize()
endFullscreen modes
Fullscreen uses the desktop resolution when the caller selects no mode. Exclusive fullscreen accepts only a mode that fullscreenModes or closestFullscreenMode returns.
local mode <const> = tecs.platform.window.Window.closestFullscreenMode(
savedWidth, savedHeight, savedRefreshRate, true
)
if mode ~= nil then
window:setFullscreenMode(mode)
window:setFullscreen(true)
endDisplay placement
Desktop positions span every attached display and may contain negative coordinates. Use usable bounds to keep windows clear of a taskbar, dock or menu bar.
for _, displayId in ipairs(tecs.platform.window.Window.displays()) do
local x <const>, y <const>, width <const>, height <const> = tecs.platform.window.Window.usableBounds(
displayId
)
endDisplay and window events report changes. Getters report current state, including state that existed before the first event. Use Window:id to match a window event's which field.
Custom window chrome
A borderless window can return selected regions to the desktop for dragging and edge resizing. setHitRegions copies the complete list, so UI layout may reuse or change its records as soon as the call returns. The first region that contains a point wins.
window:setHitRegions({
{kind = "draggable", x = 0, y = 0, width = 800, height = 40},
{kind = "resizeBottom", x = 0, y = 596, width = 800, height = 4},
})Hit testing runs inside the native window manager callback. Rust reads the copied regions there; SDL never calls a Lua function.
Pointer ownership
The window API owns mouse and keyboard confinement. tecs.input owns relative mouse mode, warping, capture and cursor visibility. The GPU device owns presentation pacing after it claims a window.
Module contents
Constructors
| Constructor | Description |
|---|---|
newWindow |
Opens a window and raises when it cannot create a usable one. |
Types
| Type | Kind | Description |
|---|---|---|
DisplayMode |
type | Describes one fullscreen mode a display offers. |
Flash |
type | Selects how a window asks for attention. |
HitRegion |
type | Describes one custom window region. |
HitRegionKind |
type | Selects how the desktop treats a custom window region. |
Options |
type | Describes the caller-writable configuration that newWindow reads. |
Orientation |
type | Describes which way up a display is. |
Progress |
type | Selects what a taskbar progress indicator shows. |
Theme |
type | Describes the desktop's light or dark preference. |
Window |
record | A Window owns one open OS window and reads the displays around it. |
Constructors
tecs.platform.window.newWindow Static
Opens a window and raises when it cannot create a usable one.
It validates sizes and the icon before returning. Omitted fields take the defaults that Options documents.
Arguments
| Name | Type | Description |
|---|---|---|
options |
Window.Options |
The caller supplies the initial window configuration. |
Returns
| Type | Description |
|---|---|
Window |
Returns the caller-owned window. The caller releases it through destroy. |
Types
tecs.platform.window.DisplayMode type
Describes one fullscreen mode a display offers.
type tecs.platform.window.DisplayMode = Window.DisplayModetecs.platform.window.Flash type
Selects how a window asks for attention.
tecs.platform.window.HitRegion type
Describes one custom window region.
tecs.platform.window.HitRegionKind type
Selects how the desktop treats a custom window region.
type tecs.platform.window.HitRegionKind = Window.HitRegionKindtecs.platform.window.Options type
Describes the caller-writable configuration that newWindow reads.
tecs.platform.window.Orientation type
Describes which way up a display is.
type tecs.platform.window.Orientation = Window.Orientationtecs.platform.window.Progress type
Selects what a taskbar progress indicator shows.
tecs.platform.window.Theme type
Describes the desktop's light or dark preference.
tecs.platform.window.Window record
A Window owns one open OS window and reads the displays around it.
Game code changes state through methods. Public fields expose framework state and remain read-only to callers.
record tecs.platform.window.Window
handle: loader.CPtr
title: string
enum Orientation
"landscape"
"landscapeFlipped"
"portrait"
"portraitFlipped"
"unknown"
end
enum Theme
"dark"
"light"
"unknown"
end
enum Flash
"brief"
"cancel"
"untilFocused"
end
enum Progress
"error"
"indeterminate"
"none"
"normal"
"paused"
end
enum HitRegionKind
"draggable"
"resizeBottom"
"resizeBottomLeft"
"resizeBottomRight"
"resizeLeft"
"resizeRight"
"resizeTop"
"resizeTopLeft"
"resizeTopRight"
end
record HitRegion
kind: HitRegionKind
x: integer
y: integer
width: integer
height: integer
end
record DisplayMode
display: integer
width: integer
height: integer
pixelDensity: number
refreshRate: number
end
record Options
title: string
width: integer
height: integer
resizable: boolean
highPixelDensity: boolean
fullscreen: boolean
borderless: boolean
hidden: boolean
alwaysOnTop: boolean
transparent: boolean
x: integer
y: integer
minWidth: integer
minHeight: integer
maxWidth: integer
maxHeight: integer
icon: string
end
closestFullscreenMode: function(
width: integer,
height: integer,
refreshRate: number,
highDensity: boolean,
displayId: integer
): Window.DisplayMode
contentScale: function(displayId: integer): number
currentMode: function(displayId: integer): Window.DisplayMode
desktopMode: function(displayId: integer): Window.DisplayMode
displayBounds: function(
displayId: integer
): integer, integer, integer, integer
displayName: function(displayId: integer): string
displays: function(): {integer}
fullscreenModes: function(displayId: integer): {Window.DisplayMode}
isSupported: function(): boolean
naturalOrientation: function(displayId: integer): Window.Orientation
orientation: function(displayId: integer): Window.Orientation
primaryDisplay: function(): integer
screenSaverEnabled: function(): boolean
setScreenSaverEnabled: function(enabled: boolean): boolean
theme: function(): Window.Theme
usableBounds: function(
displayId: integer
): integer, integer, integer, integer
aspectRatio: function(self): number, number
borderSize: function(self): integer, integer, integer, integer
center: function(self, displayId: integer): boolean
destroy: function(self)
display: function(self): integer
displayScale: function(self): number
flash: function(self, operation: Window.Flash): boolean
fullscreenMode: function(self): Window.DisplayMode
getPixelSize: function(self): integer, integer
getSize: function(self): integer, integer
hasFocus: function(self): boolean
hasMouseFocus: function(self): boolean
hide: function(self): boolean
id: function(self): integer
isAlwaysOnTop: function(self): boolean
isBordered: function(self): boolean
isFocusable: function(self): boolean
isFullscreen: function(self): boolean
isMaximized: function(self): boolean
isMinimized: function(self): boolean
isOccluded: function(self): boolean
isResizable: function(self): boolean
isVisible: function(self): boolean
keyboardGrab: function(self): boolean
maximize: function(self): boolean
maximumSize: function(self): integer, integer
minimize: function(self): boolean
minimumSize: function(self): integer, integer
mouseGrab: function(self): boolean
mouseRect: function(self): integer, integer, integer, integer
opacity: function(self): number
pixelDensity: function(self): number
position: function(self): integer, integer
progress: function(self): Window.Progress, number
raise: function(self): boolean
restore: function(self): boolean
safeArea: function(self): integer, integer, integer, integer
setAlwaysOnTop: function(self, onTop: boolean): boolean
setAspectRatio: function(
self, minimum: number, maximum: number
): boolean
setBordered: function(self, bordered: boolean): boolean
setFocusable: function(self, focusable: boolean): boolean
setFullscreen: function(self, fullscreen: boolean): boolean
setFullscreenMode: function(self, mode: Window.DisplayMode): boolean
setHitRegions: function(self, regions: {Window.HitRegion}): boolean
setIcon: function(self, path: string): boolean
setKeyboardGrab: function(self, grabbed: boolean): boolean
setMaximumSize: function(
self, width: integer, height: integer
): boolean
setMinimumSize: function(
self, width: integer, height: integer
): boolean
setMouseGrab: function(self, grabbed: boolean): boolean
setMouseRect: function(
self, x: integer, y: integer, width: integer, height: integer
): boolean
setOpacity: function(self, opacity: number): boolean
setPosition: function(self, x: integer, y: integer): boolean
setProgress: function(
self, state: Window.Progress, value: number
): boolean
setResizable: function(self, resizable: boolean): boolean
setSize: function(self, width: integer, height: integer): boolean
setTitle: function(self, title: string): boolean
show: function(self): boolean
showSystemMenu: function(self, x: integer, y: integer): boolean
sync: function(self): boolean
endtecs.platform.window.Window.handle field
Engine-owned. The framework stores the native window handle here for the GPU device to claim for presentation and sets it to nil when destroy runs. Ordinary game code ignores this field.
tecs.platform.window.Window.title field
Read-only. The framework stores the last title here when it creates the window or setTitle succeeds. Game code changes it through setTitle.
tecs.platform.window.Window.Orientation enum
Orientation describes a display's current or natural rotation.
enum tecs.platform.window.Window.Orientation
"landscape"
"landscapeFlipped"
"portrait"
"portraitFlipped"
"unknown"
endtecs.platform.window.Window.Theme enum
Theme describes the desktop's requested appearance.
enum tecs.platform.window.Window.Theme
"dark"
"light"
"unknown"
endtecs.platform.window.Window.Flash enum
Flash selects how long the desktop asks for attention.
enum tecs.platform.window.Window.Flash
"brief"
"cancel"
"untilFocused"
endtecs.platform.window.Window.Progress enum
Progress selects what the taskbar or dock shows over the icon.
enum tecs.platform.window.Window.Progress
"error"
"indeterminate"
"none"
"normal"
"paused"
endtecs.platform.window.Window.HitRegionKind enum
HitRegionKind selects how the desktop treats a window region.
enum tecs.platform.window.Window.HitRegionKind
"draggable"
"resizeBottom"
"resizeBottomLeft"
"resizeBottomRight"
"resizeLeft"
"resizeRight"
"resizeTop"
"resizeTopLeft"
"resizeTopRight"
endtecs.platform.window.Window.HitRegion record
HitRegion gives part of a borderless window desktop behavior.
record tecs.platform.window.Window.HitRegion
kind: HitRegionKind
x: integer
y: integer
width: integer
height: integer
endtecs.platform.window.Window.HitRegion.kind field
Caller-writable. Selects dragging or one resize direction.
tecs.platform.window.Window.HitRegion.x field
Caller-writable. Sets the left edge in window client coordinates. It must be a non-negative integer.
tecs.platform.window.Window.HitRegion.y field
Caller-writable. Sets the top edge in window client coordinates. It must be a non-negative integer.
tecs.platform.window.Window.HitRegion.width field
Caller-writable. Sets a positive width in window client coordinates.
tecs.platform.window.Window.HitRegion.height field
Caller-writable. Sets a positive height in window client coordinates.
tecs.platform.window.Window.DisplayMode record
DisplayMode describes one video mode returned by the platform.
Callers treat every field as read-only and pass the record back to setFullscreenMode.
record tecs.platform.window.Window.DisplayMode
display: integer
width: integer
height: integer
pixelDensity: number
refreshRate: number
endtecs.platform.window.Window.DisplayMode.display field
Read-only. The platform sets display when it builds the mode.
tecs.platform.window.Window.DisplayMode.display: integertecs.platform.window.Window.DisplayMode.width field
Read-only. The platform sets width in screen coordinates when it builds the mode. Callers multiply it by pixelDensity to obtain pixels.
tecs.platform.window.Window.DisplayMode.width: integertecs.platform.window.Window.DisplayMode.height field
Read-only. The platform sets height in screen coordinates when it builds the mode. Callers multiply it by pixelDensity to obtain pixels.
tecs.platform.window.Window.DisplayMode.height: integertecs.platform.window.Window.DisplayMode.pixelDensity field
Read-only. The platform sets pixelDensity when it builds the mode. A 1920 by 1080 mode at 2.0 draws 3840 by 2160 pixels.
tecs.platform.window.Window.DisplayMode.pixelDensity: numbertecs.platform.window.Window.DisplayMode.refreshRate field
Read-only. The platform sets refreshRate in hertz when it builds the mode, or to zero when it cannot report a rate.
tecs.platform.window.Window.DisplayMode.refreshRate: numbertecs.platform.window.Window.Options record
Callers may set any Options field before passing the record to newWindow. The function reads the values and does not retain the record.
record tecs.platform.window.Window.Options
title: string
width: integer
height: integer
resizable: boolean
highPixelDensity: boolean
fullscreen: boolean
borderless: boolean
hidden: boolean
alwaysOnTop: boolean
transparent: boolean
x: integer
y: integer
minWidth: integer
minHeight: integer
maxWidth: integer
maxHeight: integer
icon: string
endtecs.platform.window.Window.Options.title field
Caller-writable. The caller sets title to the desktop title before newWindow reads it. It defaults to "tecs".
tecs.platform.window.Window.Options.width field
Caller-writable. The caller sets width in screen coordinates before newWindow reads it. It defaults to 1280.
tecs.platform.window.Window.Options.height field
Caller-writable. The caller sets height in screen coordinates before newWindow reads it. It defaults to 720.
tecs.platform.window.Window.Options.resizable field
Caller-writable. The caller sets resizable before newWindow reads it. It defaults to true, and only false disables edge resizing.
tecs.platform.window.Window.Options.highPixelDensity field
Caller-writable. The caller sets highPixelDensity before newWindow reads it. It defaults to true and lets the drawable follow the display density instead of stretching.
tecs.platform.window.Window.Options.highPixelDensity: booleantecs.platform.window.Window.Options.fullscreen field
Caller-writable. The caller sets fullscreen before newWindow reads it to start on the display selected by the window manager. It defaults to false.
tecs.platform.window.Window.Options.fullscreen: booleantecs.platform.window.Window.Options.borderless field
Caller-writable. The caller sets borderless before newWindow reads it to remove the title bar and frame. It defaults to false.
tecs.platform.window.Window.Options.borderless: boolean
tecs.platform.window.Window.Options.hidden field
Caller-writable. The caller sets hidden before newWindow reads it to defer mapping until show. It defaults to false.
tecs.platform.window.Window.Options.alwaysOnTop field
Caller-writable. The caller sets alwaysOnTop before newWindow reads it to keep the window above others. It defaults to false.
tecs.platform.window.Window.Options.alwaysOnTop: booleantecs.platform.window.Window.Options.transparent field
Caller-writable. The caller sets transparent before newWindow reads it to request desktop alpha compositing. It defaults to false.
tecs.platform.window.Window.Options.transparent: booleantecs.platform.window.Window.Options.x field
Caller-writable. The caller sets x with y before newWindow reads them. Without both fields, the window manager chooses the position.
tecs.platform.window.Window.Options.y field
Caller-writable. The caller sets y with x before newWindow reads them.
tecs.platform.window.Window.Options.minWidth field
Caller-writable. The caller sets minWidth with minHeight before newWindow reads them.
tecs.platform.window.Window.Options.minHeight field
Caller-writable. The caller sets minHeight with minWidth before newWindow reads them.
tecs.platform.window.Window.Options.maxWidth field
Caller-writable. The caller sets maxWidth with maxHeight before newWindow reads them.
tecs.platform.window.Window.Options.maxHeight field
Caller-writable. The caller sets maxHeight with maxWidth before newWindow reads them.
tecs.platform.window.Window.Options.icon field
Caller-writable. The caller sets icon to an image path before newWindow reads it. newWindow decodes it synchronously.
tecs.platform.window.Window.closestFullscreenMode Static
Finds the nearest fullscreen mode to a requested size.
Use this when restoring a saved mode that the display may no longer offer exactly.
function tecs.platform.window.Window.closestFullscreenMode(
width: integer,
height: integer,
refreshRate: number,
highDensity: boolean,
displayId: integer
): Window.DisplayModeArguments
| Name | Type | Description |
|---|---|---|
width |
integer |
The caller supplies the requested width in screen coordinates. |
height |
integer |
The caller supplies the requested height in screen coordinates. |
refreshRate |
number |
The caller supplies hertz, or zero or nil for the highest available rate. |
highDensity |
boolean |
The caller chooses whether the function may select modes above density 1. It defaults to false. |
displayId |
integer |
The caller omits this value to use the primary display. |
Returns
| Type | Description |
|---|---|
Window.DisplayMode |
Returns the nearest platform mode, or nil when none fits. |
tecs.platform.window.Window.contentScale Static
Reads a display's preferred content scale.
function tecs.platform.window.Window.contentScale(
displayId: integer
): numberArguments
| Name | Type | Description |
|---|---|---|
displayId |
integer |
The caller omits this value to use the primary display. |
Returns
| Type | Description |
|---|---|
number |
Returns the scale, or zero without video. |
tecs.platform.window.Window.currentMode Static
Reads the display mode in use now.
function tecs.platform.window.Window.currentMode(
displayId: integer
): Window.DisplayModeArguments
| Name | Type | Description |
|---|---|---|
displayId |
integer |
The caller omits this value to use the primary display. |
Returns
| Type | Description |
|---|---|
Window.DisplayMode |
Returns the mode, or nil without video. |
tecs.platform.window.Window.desktopMode Static
Reads the display mode the desktop started in.
function tecs.platform.window.Window.desktopMode(
displayId: integer
): Window.DisplayModeArguments
| Name | Type | Description |
|---|---|---|
displayId |
integer |
The caller omits this value to use the primary display. |
Returns
| Type | Description |
|---|---|
Window.DisplayMode |
Returns the mode, or nil without video. |
tecs.platform.window.Window.displayBounds Static
Reads a display's desktop rectangle.
function tecs.platform.window.Window.displayBounds(
displayId: integer
): integer, integer, integer, integerArguments
| Name | Type | Description |
|---|---|---|
displayId |
integer |
The caller omits this value to use the primary display. |
Returns
| Type | Description |
|---|---|
integer |
Returns the horizontal position in desktop screen coordinates. |
integer |
Returns the vertical position in desktop screen coordinates. |
integer |
Returns the width in screen coordinates. |
integer |
Returns the height in screen coordinates. |
tecs.platform.window.Window.displayName Static
Reads the desktop name for a display.
function tecs.platform.window.Window.displayName(
displayId: integer
): stringArguments
| Name | Type | Description |
|---|---|---|
displayId |
integer |
The caller omits this value to use the primary display. |
Returns
| Type | Description |
|---|---|
string |
Returns the name, or an empty string without video. |
tecs.platform.window.Window.displays Static
Lists attached displays in platform order.
function tecs.platform.window.Window.displays(): {integer}Arguments
None.
Returns
| Type | Description |
|---|---|
{integer} |
Returns display ids, or an empty list without video. |
tecs.platform.window.Window.fullscreenModes Static
Lists the display's exclusive fullscreen modes, largest first.
function tecs.platform.window.Window.fullscreenModes(
displayId: integer
): {Window.DisplayMode}Arguments
| Name | Type | Description |
|---|---|---|
displayId |
integer |
The caller omits this value to use the primary display. |
Returns
| Type | Description |
|---|---|
{Window.DisplayMode} |
Returns modes accepted by setFullscreenMode, or an empty list without video. |
tecs.platform.window.Window.isSupported Static
Returns whether the platform can create and inspect windows.
False in a headless process. Display and screen-saver functions answer harmless defaults there, while newWindow raises.
function tecs.platform.window.Window.isSupported(): booleanArguments
None.
Returns
| Type | Description |
|---|---|
boolean |
Returns true when this process can create and inspect windows. |
tecs.platform.window.Window.naturalOrientation Static
Reads the orientation a display was built for.
function tecs.platform.window.Window.naturalOrientation(
displayId: integer
): Window.OrientationArguments
| Name | Type | Description |
|---|---|---|
displayId |
integer |
The caller omits this value to use the primary display. |
Returns
| Type | Description |
|---|---|
Window.Orientation |
Returns the natural orientation, or "unknown" without video. |
tecs.platform.window.Window.orientation Static
Reads a display's current rotation.
function tecs.platform.window.Window.orientation(
displayId: integer
): Window.OrientationArguments
| Name | Type | Description |
|---|---|---|
displayId |
integer |
The caller omits this value to use the primary display. |
Returns
| Type | Description |
|---|---|
Window.Orientation |
Returns the orientation, or "unknown" without video. |
tecs.platform.window.Window.primaryDisplay Static
Reads the desktop's primary display.
function tecs.platform.window.Window.primaryDisplay(): integerArguments
None.
Returns
| Type | Description |
|---|---|
integer |
Returns the display id, or zero without video. |
tecs.platform.window.Window.screenSaverEnabled Static
Returns whether the desktop may blank the display.
Video startup disables the screen saver. Enable it for an unattended menu or cutscene.
function tecs.platform.window.Window.screenSaverEnabled(): booleanArguments
None.
Returns
| Type | Description |
|---|---|
boolean |
Returns false without video. |
tecs.platform.window.Window.setScreenSaverEnabled Static
Allows or forbids the desktop blanking the display.
function tecs.platform.window.Window.setScreenSaverEnabled(
enabled: boolean
): booleanArguments
| Name | Type | Description |
|---|---|---|
enabled |
boolean |
The caller chooses whether the screen saver may run. |
Returns
| Type | Description |
|---|---|
boolean |
Returns whether the platform accepted the change, or false without video. |
tecs.platform.window.Window.theme Static
Reads the desktop's light or dark preference.
Arguments
None.
Returns
| Type | Description |
|---|---|
Window.Theme |
Returns "light", "dark" or "unknown". |
tecs.platform.window.Window.usableBounds Static
Reads the display area not occupied by desktop chrome.
function tecs.platform.window.Window.usableBounds(
displayId: integer
): integer, integer, integer, integerArguments
| Name | Type | Description |
|---|---|---|
displayId |
integer |
The caller omits this value to use the primary display. |
Returns
| Type | Description |
|---|---|
integer |
Returns the horizontal position in desktop screen coordinates. |
integer |
Returns the vertical position in desktop screen coordinates. |
integer |
Returns the width in screen coordinates. |
integer |
Returns the height in screen coordinates. |
tecs.platform.window.Window:aspectRatio Instance
Reads the allowed width-over-height range.
function tecs.platform.window.Window.aspectRatio(self): number, numberArguments
| Name | Type | Description |
|---|---|---|
self |
Window |
Returns
| Type | Description |
|---|---|
number |
Returns the minimum ratio, or zero when unset. |
number |
Returns the maximum ratio, or zero when unset. |
tecs.platform.window.Window:borderSize Instance
Reads the window decoration thickness in screen coordinates.
function tecs.platform.window.Window.borderSize(
self
): integer, integer, integer, integerArguments
| Name | Type | Description |
|---|---|---|
self |
Window |
Returns
| Type | Description |
|---|---|
integer |
Returns the top thickness, or zero without decoration. |
integer |
Returns the left thickness, or zero without decoration. |
integer |
Returns the bottom thickness, or zero without decoration. |
integer |
Returns the right thickness, or zero without decoration. |
tecs.platform.window.Window:center Instance
Centers the window on a display.
function tecs.platform.window.Window.center(
self, displayId: integer
): booleanArguments
| Name | Type | Description |
|---|---|---|
self |
Window |
|
displayId |
integer |
The caller omits this value to use the display the window occupies. |
Returns
| Type | Description |
|---|---|
boolean |
Returns whether the platform accepted the request. |
tecs.platform.window.Window:destroy Instance
Releases the window. Safe to call more than once.
Every getter answers zero, false or nil after this call.
function tecs.platform.window.Window.destroy(self)Arguments
| Name | Type | Description |
|---|---|---|
self |
Window |
Returns
None.
tecs.platform.window.Window:display Instance
Reads the display this window mostly occupies.
function tecs.platform.window.Window.display(self): integerArguments
| Name | Type | Description |
|---|---|---|
self |
Window |
Returns
| Type | Description |
|---|---|
integer |
Returns the display id, or zero after destroy. |
tecs.platform.window.Window:displayScale Instance
Returns the desktop's preferred scale for content.
This is not the ratio between getSize and getPixelSize; use pixelDensity for that. A theme or UI can multiply its natural metrics by this value.
function tecs.platform.window.Window.displayScale(self): numberArguments
| Name | Type | Description |
|---|---|---|
self |
Window |
Returns
| Type | Description |
|---|---|
number |
Returns the scale, or zero after destroy. |
tecs.platform.window.Window:flash Instance
Asks for attention without taking focus.
"untilFocused" keeps asking and "cancel" stops a request. An unknown operation raises.
Arguments
| Name | Type | Description |
|---|---|---|
self |
Window |
|
operation |
Window.Flash |
The caller chooses how long to ask for attention. |
Returns
| Type | Description |
|---|---|
boolean |
Returns whether the desktop accepted the request. |
tecs.platform.window.Window:fullscreenMode Instance
Reads the selected exclusive fullscreen mode.
function tecs.platform.window.Window.fullscreenMode(
self
): Window.DisplayModeArguments
| Name | Type | Description |
|---|---|---|
self |
Window |
Returns
| Type | Description |
|---|---|
Window.DisplayMode |
Returns the mode, or nil for borderless fullscreen and after destroy. |
tecs.platform.window.Window:getPixelSize Instance
Reads the drawable size in pixels.
function tecs.platform.window.Window.getPixelSize(
self
): integer, integerArguments
| Name | Type | Description |
|---|---|---|
self |
Window |
Returns
| Type | Description |
|---|---|
integer |
Returns the pixel width, or zero after destroy. |
integer |
Returns the pixel height, or zero after destroy. |
tecs.platform.window.Window:getSize Instance
Reads the window size in screen coordinates.
Pointer positions use these units. Render targets use getPixelSize.
function tecs.platform.window.Window.getSize(self): integer, integerArguments
| Name | Type | Description |
|---|---|---|
self |
Window |
Returns
| Type | Description |
|---|---|
integer |
Returns the width, or zero after destroy. |
integer |
Returns the height, or zero after destroy. |
tecs.platform.window.Window:hasFocus Instance
Returns whether keyboard events currently target this window.
function tecs.platform.window.Window.hasFocus(self): booleanArguments
| Name | Type | Description |
|---|---|---|
self |
Window |
Returns
| Type | Description |
|---|---|
boolean |
Returns false after destroy. |
tecs.platform.window.Window:hasMouseFocus Instance
Returns whether the pointer is over the window.
Relative mouse mode has no pointer position and reports false.
function tecs.platform.window.Window.hasMouseFocus(self): booleanArguments
| Name | Type | Description |
|---|---|---|
self |
Window |
Returns
| Type | Description |
|---|---|
boolean |
Returns false after destroy. |
tecs.platform.window.Window:hide Instance
Unmaps the window without destroying it.
A claimed swapchain yields no texture while the desktop hides the window.
function tecs.platform.window.Window.hide(self): booleanArguments
| Name | Type | Description |
|---|---|---|
self |
Window |
Returns
| Type | Description |
|---|---|
boolean |
Returns whether the platform hid the window. |
tecs.platform.window.Window:id Instance
Returns the id carried in a window event's which field.
function tecs.platform.window.Window.id(self): integerArguments
| Name | Type | Description |
|---|---|---|
self |
Window |
Returns
| Type | Description |
|---|---|
integer |
Returns the platform window id, or zero after destroy. |
tecs.platform.window.Window:isAlwaysOnTop Instance
Returns whether the desktop keeps the window above others.
function tecs.platform.window.Window.isAlwaysOnTop(self): booleanArguments
| Name | Type | Description |
|---|---|---|
self |
Window |
Returns
| Type | Description |
|---|---|
boolean |
Returns false after destroy. |
tecs.platform.window.Window:isBordered Instance
Returns whether the window has a title bar and frame.
function tecs.platform.window.Window.isBordered(self): booleanArguments
| Name | Type | Description |
|---|---|---|
self |
Window |
Returns
| Type | Description |
|---|---|
boolean |
Returns false after destroy. |
tecs.platform.window.Window:isFocusable Instance
Returns whether the window may take keyboard focus.
function tecs.platform.window.Window.isFocusable(self): booleanArguments
| Name | Type | Description |
|---|---|---|
self |
Window |
Returns
| Type | Description |
|---|---|
boolean |
Returns false after destroy. |
tecs.platform.window.Window:isFullscreen Instance
Returns whether the window occupies a fullscreen display.
function tecs.platform.window.Window.isFullscreen(self): booleanArguments
| Name | Type | Description |
|---|---|---|
self |
Window |
Returns
| Type | Description |
|---|---|
boolean |
Returns false after destroy. |
tecs.platform.window.Window:isMaximized Instance
Returns whether the window fills the display's usable bounds.
function tecs.platform.window.Window.isMaximized(self): booleanArguments
| Name | Type | Description |
|---|---|---|
self |
Window |
Returns
| Type | Description |
|---|---|
boolean |
Returns false after destroy. |
tecs.platform.window.Window:isMinimized Instance
Returns whether the window occupies its minimized state.
function tecs.platform.window.Window.isMinimized(self): booleanArguments
| Name | Type | Description |
|---|---|---|
self |
Window |
Returns
| Type | Description |
|---|---|
boolean |
Returns false after destroy. |
tecs.platform.window.Window:isOccluded Instance
Returns whether other windows cover this window completely.
function tecs.platform.window.Window.isOccluded(self): booleanArguments
| Name | Type | Description |
|---|---|---|
self |
Window |
Returns
| Type | Description |
|---|---|
boolean |
Returns false after destroy. |
tecs.platform.window.Window:isResizable Instance
Returns whether the user can resize the window by dragging an edge.
function tecs.platform.window.Window.isResizable(self): booleanArguments
| Name | Type | Description |
|---|---|---|
self |
Window |
Returns
| Type | Description |
|---|---|
boolean |
Returns false after destroy. |
tecs.platform.window.Window:isVisible Instance
Returns whether the desktop shows the window.
Minimizing the window does not hide it.
function tecs.platform.window.Window.isVisible(self): booleanArguments
| Name | Type | Description |
|---|---|---|
self |
Window |
Returns
| Type | Description |
|---|---|
boolean |
Returns false for a hidden or destroyed window. |
tecs.platform.window.Window:keyboardGrab Instance
Returns whether the window intercepts desktop keyboard shortcuts.
function tecs.platform.window.Window.keyboardGrab(self): booleanArguments
| Name | Type | Description |
|---|---|---|
self |
Window |
Returns
| Type | Description |
|---|---|
boolean |
Returns false after destroy. |
tecs.platform.window.Window:maximize Instance
Maximizes the window to the display's usable bounds.
function tecs.platform.window.Window.maximize(self): booleanArguments
| Name | Type | Description |
|---|---|---|
self |
Window |
Returns
| Type | Description |
|---|---|
boolean |
Returns whether the platform accepted the request. |
tecs.platform.window.Window:maximumSize Instance
Reads the maximum resize limit.
function tecs.platform.window.Window.maximumSize(self): integer, integerArguments
| Name | Type | Description |
|---|---|---|
self |
Window |
Returns
| Type | Description |
|---|---|
integer |
Returns the maximum width, or zero when unset. |
integer |
Returns the maximum height, or zero when unset. |
tecs.platform.window.Window:minimize Instance
Minimizes the window to the taskbar or dock.
function tecs.platform.window.Window.minimize(self): booleanArguments
| Name | Type | Description |
|---|---|---|
self |
Window |
Returns
| Type | Description |
|---|---|
boolean |
Returns whether the platform accepted the request. |
tecs.platform.window.Window:minimumSize Instance
Reads the minimum resize limit.
function tecs.platform.window.Window.minimumSize(self): integer, integerArguments
| Name | Type | Description |
|---|---|---|
self |
Window |
Returns
| Type | Description |
|---|---|
integer |
Returns the minimum width, or zero when unset. |
integer |
Returns the minimum height, or zero when unset. |
tecs.platform.window.Window:mouseGrab Instance
Returns whether pointer confinement applies to the focused window.
function tecs.platform.window.Window.mouseGrab(self): booleanArguments
| Name | Type | Description |
|---|---|---|
self |
Window |
Returns
| Type | Description |
|---|---|
boolean |
Returns false when the window lacks focus or after destroy. |
tecs.platform.window.Window:mouseRect Instance
Reads the pointer confinement region.
function tecs.platform.window.Window.mouseRect(
self
): integer, integer, integer, integerArguments
| Name | Type | Description |
|---|---|---|
self |
Window |
Returns
| Type | Description |
|---|---|
integer |
Returns the horizontal offset in screen coordinates. |
integer |
Returns the vertical offset in screen coordinates. |
integer |
Returns the width in screen coordinates. |
integer |
Returns the height in screen coordinates. All four values contain zero when unset. |
tecs.platform.window.Window:opacity Instance
Reads the window opacity.
function tecs.platform.window.Window.opacity(self): numberArguments
| Name | Type | Description |
|---|---|---|
self |
Window |
Returns
| Type | Description |
|---|---|
number |
Returns a value from 0 for invisible to 1 for solid, zero after destroy, or 1 on a platform without compositing. |
tecs.platform.window.Window:pixelDensity Instance
Returns the ratio of drawable pixels to screen coordinates.
function tecs.platform.window.Window.pixelDensity(self): numberArguments
| Name | Type | Description |
|---|---|---|
self |
Window |
Returns
| Type | Description |
|---|---|
number |
Returns the ratio, 1 without high-density drawing, or zero after destroy. |
tecs.platform.window.Window:position Instance
Reads the top-left corner in desktop screen coordinates.
function tecs.platform.window.Window.position(self): integer, integerArguments
| Name | Type | Description |
|---|---|---|
self |
Window |
Returns
| Type | Description |
|---|---|
integer |
Returns the horizontal position, or zero after destroy. |
integer |
Returns the vertical position, or zero after destroy. |
tecs.platform.window.Window:progress Instance
Reads taskbar or dock progress.
Arguments
| Name | Type | Description |
|---|---|---|
self |
Window |
Returns
| Type | Description |
|---|---|
Window.Progress |
Returns the current state, or "none" after destroy. |
number |
Returns progress from 0 to 1, or zero after destroy. |
tecs.platform.window.Window:raise Instance
Brings the window forward and requests input focus.
Prefer flash when the user did not request a focus change.
function tecs.platform.window.Window.raise(self): booleanArguments
| Name | Type | Description |
|---|---|---|
self |
Window |
Returns
| Type | Description |
|---|---|
boolean |
Returns whether the platform accepted the request. |
tecs.platform.window.Window:restore Instance
Restores a minimized or maximized window.
function tecs.platform.window.Window.restore(self): booleanArguments
| Name | Type | Description |
|---|---|---|
self |
Window |
Returns
| Type | Description |
|---|---|
boolean |
Returns whether the platform accepted the request. |
tecs.platform.window.Window:safeArea Instance
Reads the unobstructed region inside the window.
A desktop normally returns the whole window. Phones and handhelds may exclude notches, rounded corners or gesture areas.
function tecs.platform.window.Window.safeArea(
self
): integer, integer, integer, integerArguments
| Name | Type | Description |
|---|---|---|
self |
Window |
Returns
| Type | Description |
|---|---|
integer |
Returns the horizontal offset in screen coordinates. |
integer |
Returns the vertical offset in screen coordinates. |
integer |
Returns the width in screen coordinates. |
integer |
Returns the height in screen coordinates. |
tecs.platform.window.Window:setAlwaysOnTop Instance
Enables or disables always-on-top behavior.
function tecs.platform.window.Window.setAlwaysOnTop(
self, onTop: boolean
): booleanArguments
| Name | Type | Description |
|---|---|---|
self |
Window |
|
onTop |
boolean |
The caller chooses whether to keep the window above others. |
Returns
| Type | Description |
|---|---|
boolean |
Returns whether the platform accepted the change. |
tecs.platform.window.Window:setAspectRatio Instance
Constrains the width-over-height ratio.
Equal values pin the window to one shape.
function tecs.platform.window.Window.setAspectRatio(
self, minimum: number, maximum: number
): booleanArguments
| Name | Type | Description |
|---|---|---|
self |
Window |
|
minimum |
number |
The caller supplies the minimum ratio, or zero to remove that bound. |
maximum |
number |
The caller supplies the maximum ratio, or zero to remove that bound. |
Returns
| Type | Description |
|---|---|
boolean |
Returns whether the platform accepted the bounds. |
tecs.platform.window.Window:setBordered Instance
Adds or removes the title bar and frame.
The client area keeps its size.
function tecs.platform.window.Window.setBordered(
self, bordered: boolean
): booleanArguments
| Name | Type | Description |
|---|---|---|
self |
Window |
|
bordered |
boolean |
The caller chooses whether to show desktop decoration. |
Returns
| Type | Description |
|---|---|
boolean |
Returns whether the platform accepted the change. |
tecs.platform.window.Window:setFocusable Instance
Allows or forbids keyboard focus.
A non-focusable window suits an overlay.
function tecs.platform.window.Window.setFocusable(
self, focusable: boolean
): booleanArguments
| Name | Type | Description |
|---|---|---|
self |
Window |
|
focusable |
boolean |
The caller chooses whether the window may take focus. |
Returns
| Type | Description |
|---|---|
boolean |
Returns whether the platform accepted the change. |
tecs.platform.window.Window:setFullscreen Instance
Enters or leaves fullscreen.
With no selected mode, fullscreen uses the desktop resolution. With a mode from setFullscreenMode, it changes the display mode. The swapchain follows the new size on the next acquired frame.
function tecs.platform.window.Window.setFullscreen(
self, fullscreen: boolean
): booleanArguments
| Name | Type | Description |
|---|---|---|
self |
Window |
|
fullscreen |
boolean |
The caller passes true to enter fullscreen or false to leave it. |
Returns
| Type | Description |
|---|---|
boolean |
Returns whether the platform accepted the request. |
tecs.platform.window.Window:setFullscreenMode Instance
Selects the video mode used by fullscreen.
The mode must come from fullscreenModes or closestFullscreenMode; a hand-built record raises. Nil selects borderless fullscreen at the desktop resolution.
function tecs.platform.window.Window.setFullscreenMode(
self, mode: Window.DisplayMode
): booleanArguments
| Name | Type | Description |
|---|---|---|
self |
Window |
|
mode |
Window.DisplayMode |
The caller supplies a platform mode, or nil for borderless fullscreen. |
Returns
| Type | Description |
|---|---|
boolean |
Returns whether the platform accepted the mode. |
tecs.platform.window.Window:setHitRegions Instance
Replaces the regions used for native window hit testing.
The first region containing a point wins. Left and top edges are included; right and bottom edges are excluded. SDL copies no Lua state: Rust copies every record before this call returns and answers the native callback without entering LuaJIT.
Pass nil or an empty list to restore ordinary desktop hit testing. Regions normally accompany a borderless window and must be updated after layout changes that move a title bar or resize border.
Arguments
| Name | Type | Description |
|---|---|---|
self |
Window |
|
regions |
{Window.HitRegion} |
The caller supplies special regions in priority order, or nil to clear every region. |
Returns
| Type | Description |
|---|---|
boolean |
Returns whether the platform installed, replaced or cleared the regions. |
tecs.platform.window.Window:setIcon Instance
Sets the image the desktop shows for the window.
The call decodes the file synchronously.
function tecs.platform.window.Window.setIcon(
self, path: string
): booleanArguments
| Name | Type | Description |
|---|---|---|
self |
Window |
|
path |
string |
The caller supplies the image path. Nil raises. |
Returns
| Type | Description |
|---|---|
boolean |
Returns false when the decoder cannot read the file or after destroy. |
tecs.platform.window.Window:setKeyboardGrab Instance
Enables or disables interception of desktop keyboard shortcuts.
Some desktops refuse this or require user permission.
function tecs.platform.window.Window.setKeyboardGrab(
self, grabbed: boolean
): booleanArguments
| Name | Type | Description |
|---|---|---|
self |
Window |
|
grabbed |
boolean |
The caller chooses whether to intercept shortcuts while focused. |
Returns
| Type | Description |
|---|---|
boolean |
Returns whether the platform accepted the request. |
tecs.platform.window.Window:setMaximumSize Instance
Sets the maximum resize limit.
function tecs.platform.window.Window.setMaximumSize(
self, width: integer, height: integer
): booleanArguments
| Name | Type | Description |
|---|---|---|
self |
Window |
|
width |
integer |
The caller supplies the maximum width, or zero to remove that limit. |
height |
integer |
The caller supplies the maximum height, or zero to remove that limit. |
Returns
| Type | Description |
|---|---|
boolean |
Returns whether the platform accepted the limits. |
tecs.platform.window.Window:setMinimumSize Instance
Sets the minimum resize limit.
function tecs.platform.window.Window.setMinimumSize(
self, width: integer, height: integer
): booleanArguments
| Name | Type | Description |
|---|---|---|
self |
Window |
|
width |
integer |
The caller supplies the minimum width, or zero to remove that limit. |
height |
integer |
The caller supplies the minimum height, or zero to remove that limit. |
Returns
| Type | Description |
|---|---|
boolean |
Returns whether the platform accepted the limits. |
tecs.platform.window.Window:setMouseGrab Instance
Confines the pointer to the window or releases it.
Unlike relative mouse mode, this leaves the pointer visible. An unfocused window records the request and resumes it on focus.
function tecs.platform.window.Window.setMouseGrab(
self, grabbed: boolean
): booleanArguments
| Name | Type | Description |
|---|---|---|
self |
Window |
|
grabbed |
boolean |
The caller chooses whether to confine the pointer. |
Returns
| Type | Description |
|---|---|
boolean |
Returns whether the platform accepted the request. |
tecs.platform.window.Window:setMouseRect Instance
Confines the pointer to part of the window.
This is independent of setMouseGrab. Call with no arguments to remove the region.
function tecs.platform.window.Window.setMouseRect(
self, x: integer, y: integer, width: integer, height: integer
): booleanArguments
| Name | Type | Description |
|---|---|---|
self |
Window |
|
x |
integer |
The caller supplies the horizontal offset, or nil to remove the region. |
y |
integer |
The caller supplies the vertical offset with x. |
width |
integer |
The caller supplies the region width with x. |
height |
integer |
The caller supplies the region height with x. |
Returns
| Type | Description |
|---|---|
boolean |
Returns whether the platform accepted the request. |
tecs.platform.window.Window:setOpacity Instance
Sets the window opacity.
function tecs.platform.window.Window.setOpacity(
self, opacity: number
): booleanArguments
| Name | Type | Description |
|---|---|---|
self |
Window |
|
opacity |
number |
The caller supplies a value from 0 for invisible to 1 for solid. |
Returns
| Type | Description |
|---|---|
boolean |
Returns whether the desktop accepted the change. |
tecs.platform.window.Window:setPosition Instance
Moves the window in desktop screen coordinates.
The coordinate space spans all displays and may contain negative positions.
function tecs.platform.window.Window.setPosition(
self, x: integer, y: integer
): booleanArguments
| Name | Type | Description |
|---|---|---|
self |
Window |
|
x |
integer |
The caller supplies the horizontal position. |
y |
integer |
The caller supplies the vertical position. |
Returns
| Type | Description |
|---|---|
boolean |
Returns whether the platform accepted the request. |
tecs.platform.window.Window:setProgress Instance
Shows progress on the taskbar or dock.
function tecs.platform.window.Window.setProgress(
self, state: Window.Progress, value: number
): booleanArguments
| Name | Type | Description |
|---|---|---|
self |
Window |
|
state |
Window.Progress |
The caller supplies "none", "indeterminate", "normal", "paused" or "error". An unknown value raises. |
value |
number |
The caller supplies progress from 0 to 1. The desktop reads it for "normal", "paused" and "error"; omit it to keep the current value. |
Returns
| Type | Description |
|---|---|
boolean |
Returns whether the desktop accepted the state and value. |
tecs.platform.window.Window:setResizable Instance
Allows or forbids user resizing.
function tecs.platform.window.Window.setResizable(
self, resizable: boolean
): booleanArguments
| Name | Type | Description |
|---|---|---|
self |
Window |
|
resizable |
boolean |
The caller chooses whether the user may resize the window. |
Returns
| Type | Description |
|---|---|
boolean |
Returns whether the platform accepted the change. |
tecs.platform.window.Window:setSize Instance
Resizes the window in screen coordinates.
A fullscreen window ignores the request. A compositor may apply it after this returns; use sync before an immediate readback.
function tecs.platform.window.Window.setSize(
self, width: integer, height: integer
): booleanArguments
| Name | Type | Description |
|---|---|---|
self |
Window |
|
width |
integer |
The caller supplies the new width in screen coordinates. |
height |
integer |
The caller supplies the new height in screen coordinates. |
Returns
| Type | Description |
|---|---|
boolean |
Returns whether the platform accepted the request. |
tecs.platform.window.Window:setTitle Instance
Sets the title and updates the public title field.
function tecs.platform.window.Window.setTitle(
self, title: string
): booleanArguments
| Name | Type | Description |
|---|---|---|
self |
Window |
|
title |
string |
The caller supplies the new title. Nil raises. |
Returns
| Type | Description |
|---|---|
boolean |
Returns whether the platform changed the title. |
tecs.platform.window.Window:show Instance
Maps a hidden window onto the desktop.
function tecs.platform.window.Window.show(self): booleanArguments
| Name | Type | Description |
|---|---|---|
self |
Window |
Returns
| Type | Description |
|---|---|
boolean |
Returns whether the platform showed the window. |
tecs.platform.window.Window:showSystemMenu Instance
Opens the desktop's standard menu for this window.
This supplies the platform menu used for operations such as moving the window between displays or workspaces. Unsupported desktops ignore the request.
function tecs.platform.window.Window.showSystemMenu(
self, x: integer, y: integer
): booleanArguments
| Name | Type | Description |
|---|---|---|
self |
Window |
|
x |
integer |
The caller supplies the horizontal position relative to the top-left of the window's client area. |
y |
integer |
The caller supplies the vertical position relative to the top-left of the window's client area. |
Returns
| Type | Description |
|---|---|
boolean |
Returns whether the desktop accepted the request. |
tecs.platform.window.Window:sync Instance
Waits for the compositor to apply pending window changes.
Size, position and fullscreen changes may land after their setters return. Call this only when code must read a changed value back immediately.
function tecs.platform.window.Window.sync(self): booleanArguments
| Name | Type | Description |
|---|---|---|
self |
Window |
Returns
| Type | Description |
|---|---|
boolean |
Returns false when the platform times out or after destroy. |