Skip to content

utils/popoutBounds#

availableScreen()#

function availableScreen(): {
  height: number;
  width: number;
};

The area a popout can open in: the screen of the main window, less the taskbar or dock.

Returns#

{
  height: number;
  width: number;
}

The available width and height, zero when unknown.

height#

height: number;

width#

width: number;

clampBoundsToDisplays()#

function clampBoundsToDisplays(bounds, displays): PopoutBounds | null;

Fit stored bounds onto the displays that actually exist right now.

Returns null when there is nothing sensible to restore (no bounds, no displays, degenerate size) — callers then let the OS place the window, which is always safe.

Parameters#

Parameter Type
bounds PopoutBounds | undefined
displays DisplayArea[]

Returns#

PopoutBounds | null


fitSizeToScreen()#

function fitSizeToScreen(size, screen): {
  height: number;
  width: number;
};

Cap a popout's opening size to the screen it opens on.

Parameters#

Parameter Type Description
size { height: number; width: number; } The panel's preferred size.
size.height number -
size.width number -
screen { height: number; width: number; } The available screen area; a zero side means unknown and leaves the size alone.
screen.height number -
screen.width number -

Returns#

{
  height: number;
  width: number;
}

The size to open at.

height#

height: number;

width#

width: number;

DisplayArea#

A display work area, as reported by Electron's screen module.

Properties#

height#

height: number;

width#

width: number;

x#

x: number;

y#

y: number;

PopoutBounds#

Screen-space sanity for persisted popout window positions.

A popout remembers where the user put it. Monitors come and go — undocking a laptop between sessions is routine — and a window restored onto a display that no longer exists is unreachable: it has no visible title bar to drag and no taskbar entry of its own. Every restore therefore goes through clampBoundsToDisplays first.

Properties#

height#

height: number;

width#

width: number;

x#

x: number;

y#

y: number;