콘텐츠로 이동

Monitor

이 콘텐츠는 아직 번역되지 않았습니다.

Module @netwiv/api/window · Kind Interface

import { Monitor } from '@netwiv/api/window';

Allows you to retrieve information about a given monitor.

name: string | null

Human-readable name of the monitor

position: PhysicalPosition

the Top-left corner position of the monitor relative to the larger full screen area, in physical pixels.

Note that window creation options such as x, y, width and height expect logical pixels, so convert with {@linkcode Monitor.scaleFactor} first:

import { currentMonitor } from '@netwiv/api/window';
import { WebviewWindow } from '@netwiv/api/webviewWindow';
const monitor = await currentMonitor();
if (monitor) {
const position = monitor.position.toLogical(monitor.scaleFactor);
const webview = new WebviewWindow('my-label', { x: position.x, y: position.y });
}
scaleFactor: number

The scale factor that can be used to map physical pixels to logical pixels, e.g. monitor.position.toLogical(monitor.scaleFactor).

size: PhysicalSize

The monitor’s resolution in physical pixels.

Use {@linkcode Monitor.scaleFactor} to convert to logical pixels:

const logicalSize = monitor.size.toLogical(monitor.scaleFactor);
workArea: { position: PhysicalPosition; size: PhysicalSize; }

The monitor’s work area (the monitor area excluding taskbars and docks) in physical pixels.

Use {@linkcode Monitor.scaleFactor} to convert to logical pixels as shown in {@linkcode Monitor.position}.

Upstream since 1.0.0


Descriptions come from the pinned @tauri-apps/api@2.11.1 declarations (MIT OR Apache-2.0); imports are shown with @netwiv/api paths.