Skip to content

ElectronScreen

Unofficial

Electron Screen for retrieving information about screen size, displays, cursor position, and so on.

Import:

import type { ElectronScreen } from '@obsidian-typings/obsidian-catalyst-latest';

Signature:

export interface ElectronScreen

Methods

Method Returns Description
addListener(event, listener) this Adds a listener for the display-added event.

Emitted when newDisplay has been added.
addListener(event, listener) this Adds a listener for the display-metrics-changed event.

Emitted when one or more metrics change in a display. The changedMetrics is an array of strings that describe the changes. Possible changes are bounds, workArea, scaleFactor and rotation.
addListener(event, listener) this Adds a listener for the display-removed event.

Emitted when oldDisplay has been removed.
dipToScreenPoint(point) ElectronPoint Converts a screen DIP point to a screen physical point. The DPI scale is performed relative to the display containing the DIP point.
dipToScreenRect(window, rect) ElectronRectangle Converts a screen DIP rect to a screen physical rect. The DPI scale is performed relative to the display nearest to window. If window is null, scaling will be performed to the display nearest to rect.
getAllDisplays() ElectronDisplay[] Returns an array of displays that are currently available.
getCursorScreenPoint() ElectronPoint Returns the current absolute position of the mouse pointer.

**Note:** The return value is a DIP point, not a screen physical point.
getDisplayMatching(rect) ElectronDisplay Returns the display that most closely intersects the provided bounds.
getDisplayNearestPoint(point) ElectronDisplay Returns the display nearest the specified point.
getPrimaryDisplay() ElectronDisplay Returns the primary display.
on('display-added', listener) this Registers a listener for the display-added event.
on('display-metrics-changed', listener) this Registers a listener for the display-metrics-changed event.
on('display-removed', listener) this Registers a listener for the display-removed event.
once(event, listener) this Registers a one-time listener for the display-added event. The listener is removed after it is invoked once.
once(event, listener) this Registers a one-time listener for the display-metrics-changed event. The listener is removed after it is invoked once.
once(event, listener) this Registers a one-time listener for the display-removed event. The listener is removed after it is invoked once.
removeListener(event, listener) this Removes the specified listener for the display-added event.
removeListener(event, listener) this Removes the specified listener for the display-metrics-changed event.
removeListener(event, listener) this Removes the specified listener for the display-removed event.
screenToDipPoint(point) ElectronPoint Converts a screen physical point to a screen DIP point. The DPI scale is performed relative to the display containing the physical point.
screenToDipRect(window, rect) ElectronRectangle Converts a screen physical rect to a screen DIP rect. The DPI scale is performed relative to the display nearest to window. If window is null, scaling will be performed to the display nearest to rect.

Links to this page: