Host · interface

DisplayControl

Explained in Display and the host.

interface DisplayControl
import type { DisplayControl } from '@driftengine/core';

Properties

NameTypeDescription
refreshHzreadonlynumber | nullThe refresh rate of the display the game is on, or null where the platform will not say.

Methods

mode

mode(): WindowMode

Which mode the game is in right now, read rather than remembered.

setMode

setMode(mode: WindowMode): Promise<boolean>

false where the platform refused or cannot. Never rejects.

ParameterTypeDescription
modeWindowMode

isFullscreen

isFullscreen(): boolean

setFullscreen

setFullscreen(on: boolean): Promise<void>

Never rejects. A browser refuses fullscreen outside a gesture, which is ordinary.

ParameterTypeDescription
onboolean

size

size(): { readonly width: number; readonly height: number; }

The drawing surface, in logical pixels.

canSetSize

canSetSize(): boolean

Whether setSize would work right now, asked without performing one.

More

A question rather than a mutation, since 2026-08-28. false from setSize was the only way to learn this, and setSize is the mutator — so a settings screen deciding whether to draw a resolution control at all had to call the thing that changes the window in order to find out whether it may. Reported from outside, where the workaround was a no-op probe at boot, setSize(...size()), with a paragraph explaining that it is not what it looks like.

Read on each call and not a constant, for the reason mode() is a call: a shell that can resize a window cannot resize one that is covering a display, so the answer changes with the window mode. A screen that greys its control reads this when it draws.

It must agree with setSize, and in a shell that agreement is one function rather than two conditions written twice — see ipc.ts. Two implementations of one decision drift, and here they would drift into a greyed control that works or a live one that does not.

The engine already had this shape and this surface lacked it: pad.canRumble says whether a browser can drive a pad's motors at all, beside a rumble that answers whether the call was taken. A question and a mutation, and the question is the half a settings screen draws with.

setSize

setSize(width: number, height: number): Promise<boolean>

Resize the drawing surface. false where the platform will not — a browser never can, and a shell will not while the window is covering a display.

ParameterTypeDescription
widthnumber
heightnumber

displays

displays(): readonly DisplayInfo[]

Every display the platform will admit to. Never empty where at least one is known.