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

MethodReturnsDescription
addListener(event, listener)thisAdds a listener for the display-added event.

Emitted when newDisplay has been added.
addListener(event, listener)thisAdds 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)thisAdds a listener for the display-removed event.

Emitted when oldDisplay has been removed.
dipToScreenPoint(point)ElectronPointConverts 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)ElectronRectangleConverts 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()ElectronPointReturns the current absolute position of the mouse pointer.

**Note:** The return value is a DIP point, not a screen physical point.
getDisplayMatching(rect)ElectronDisplayReturns the display that most closely intersects the provided bounds.
getDisplayNearestPoint(point)ElectronDisplayReturns the display nearest the specified point.
getPrimaryDisplay()ElectronDisplayReturns the primary display.
on('display-added', listener)thisRegisters a listener for the display-added event.
on('display-metrics-changed', listener)thisRegisters a listener for the display-metrics-changed event.
on('display-removed', listener)thisRegisters a listener for the display-removed event.
once(event, listener)thisRegisters a one-time listener for the display-added event. The listener is removed after it is invoked once.
once(event, listener)thisRegisters a one-time listener for the display-metrics-changed event. The listener is removed after it is invoked once.
once(event, listener)thisRegisters a one-time listener for the display-removed event. The listener is removed after it is invoked once.
removeListener(event, listener)thisRemoves the specified listener for the display-added event.
removeListener(event, listener)thisRemoves the specified listener for the display-metrics-changed event.
removeListener(event, listener)thisRemoves the specified listener for the display-removed event.
screenToDipPoint(point)ElectronPointConverts 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)ElectronRectangleConverts 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: