Captain is currently in ALPHA. We are happy to get your feedback
Core API
Helpers Utils Window

Module: helpers/utils/window

Table of contents

Functions

Functions

ensureVisibleOnSomeDisplay

ensureVisibleOnSomeDisplay(windowState, defaultSize): Rectangle

Ensures that the window is visible on at least one display. If the window is not visible, resets it to default size and position.

Parameters

NameTypeDescription
windowStateRectangleThe current state of the window.
defaultSizeObjectThe default size of the window.
defaultSize.heightnumber-
defaultSize.widthnumber-

Returns

Rectangle

The adjusted window state, ensuring it's visible on a display.

Defined in

src/electron/helpers/utils/window.ts:60 (opens in a new tab)


getCurrentPosition

getCurrentPosition(win): Rectangle

Retrieves the current position and size of the given BrowserWindow.

Parameters

NameTypeDescription
winBrowserWindowThe Electron BrowserWindow instance.

Returns

Rectangle

An object containing x and y coordinates, and width and height of the window.

Defined in

src/electron/helpers/utils/window.ts:10 (opens in a new tab)


resetToDefaults

resetToDefaults(defaultSize): Rectangle

Resets the window size to default values and centers it on the primary display.

Parameters

NameTypeDescription
defaultSizeObjectThe default width and height for the window.
defaultSize.heightnumber-
defaultSize.widthnumber-

Returns

Rectangle

The new window state with default size and centered position.

Defined in

src/electron/helpers/utils/window.ts:43 (opens in a new tab)


windowWithinBounds

windowWithinBounds(windowState, bounds): boolean

Checks if a window's state is within the specified bounds.

Parameters

NameTypeDescription
windowStateRectangleThe state of the window, including position and size.
boundsRectangleThe bounding rectangle to compare against.

Returns

boolean

Returns true if the window's state is within the bounds, otherwise false.

Defined in

src/electron/helpers/utils/window.ts:28 (opens in a new tab)