1. API
  2. screen

API

Methods for interacting with ToDesktop application's menu.

Remarks

This package exposes a number of methods for interacting with ToDesktop application's menu.

Functions

Function Description
dipToScreenPoint(point) Converts a screen DIP point to a screen physical point. The DPI scale is performed relative to the display containing the DIP point.
dipToScreenRect(point) 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()
getCursorScreenPoint() The current absolute position of the mouse pointer.
getDisplayMatching(rect)
getDisplayNearestPoint(point)
getPrimaryDisplay()
screenToDipPoint(point) Converts a screen physical point to a screen DIP point. The DPI scale is performed relative to the display containing the physical point.
screenToDipRect(point) 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.

dipToScreenPoint()

Converts a screen DIP point to a screen physical point. The DPI scale is performed relative to the display containing the DIP point.

Signature:

        import { screen } from "@todesktop/client-core"
screen.dipToScreenPoint(point: Point): Promise<Electron.Point>;

      
Parameters
Parameter Type Description
point Point

Returns:

Promise<Electron.Point>

dipToScreenRect()

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.

Signature:

        import { screen } from "@todesktop/client-core"
screen.dipToScreenRect(point: Point): Promise<Electron.Point>;

      
Parameters
Parameter Type Description
point Point

Returns:

Promise<Electron.Point>

getAllDisplays()

Signature:

        import { screen } from "@todesktop/client-core"
screen.getAllDisplays(): Promise<Electron.Display[]>;

      

Returns:

Promise<Electron.Display[]>

An array of displays that are currently available.

getCursorScreenPoint()

The current absolute position of the mouse pointer.

Signature:

        import { screen } from "@todesktop/client-core"
screen.getCursorScreenPoint(): Promise<Electron.Point>;

      

Returns:

Promise<Electron.Point>

The current absolute position of the mouse pointer. Note: DIP point, not a screen physical point.

getDisplayMatching()

Signature:

        import { screen } from "@todesktop/client-core"
screen.getDisplayMatching(rect: Rectangle): Promise<Electron.Display>;

      
Parameters
Parameter Type Description
rect Rectangle

Returns:

Promise<Electron.Display>

The display that most closely intersects the provided bounds.

getDisplayNearestPoint()

Signature:

        import { screen } from "@todesktop/client-core"
screen.getDisplayNearestPoint(point: Point): Promise<Electron.Display>;

      
Parameters
Parameter Type Description
point Point

Returns:

Promise<Electron.Display>

The display nearest the specified point.

getPrimaryDisplay()

Signature:

        import { screen } from "@todesktop/client-core"
screen.getPrimaryDisplay(): Promise<Electron.Display>;

      

Returns:

Promise<Electron.Display>

The primary display.

screenToDipPoint()

Converts a screen physical point to a screen DIP point. The DPI scale is performed relative to the display containing the physical point.

Signature:

        import { screen } from "@todesktop/client-core"
screen.screenToDipPoint(point: Point): Promise<Electron.Point>;

      
Parameters
Parameter Type Description
point Point

Returns:

Promise<Electron.Point>

screenToDipRect()

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.

Signature:

        import { screen } from "@todesktop/client-core"
screen.screenToDipRect(point: Point): Promise<Electron.Point>;

      
Parameters
Parameter Type Description
point Point

Returns:

Promise<Electron.Point>

Variables

Variable Description
on
removeAllListeners Unsubscribes all menu objects from the event name.

on

Signature:

        on: <E extends "display-added" | "display-removed" | "display-metrics-changed">(eventName: E, callback: NamespaceEvents<{
    "display-added": (newDisplay: Display) => void;
    "display-removed": (oldDisplay: Display) => void;
    "display-metrics-changed": (display: Display, changedMetrics: string[]) => void;
}>[E], { ref, preventDefault }?: {
    ref?: import("@todesktop/client-util").InstanceRefObject;
    preventDefault?: boolean;
}) => Promise<() => Promise<void>>

      

removeAllListeners

Unsubscribes all menu objects from the event name.

Signature:

        removeAllListeners: <E extends "display-added" | "display-removed" | "display-metrics-changed">(eventName: E, { ref, }?: {
    ref?: import("@todesktop/client-util").InstanceRefObject;
}) => Promise<void>

      

Type Aliases

TrayEvents

Signature:

        export declare type TrayEvents = NamespaceEvents<{
    "display-added": (newDisplay: Display) => void;
    "display-removed": (oldDisplay: Display) => void;
    "display-metrics-changed": (display: Display, changedMetrics: string[]) => void;
}>;

      
Type Alias Description
TrayEvents