import { EventEmitter } from "events"; import { MonitorInfoDetail, MonitorTaskbar } from "../FEA"; import { WindowIdentifier, WindowDescriptor, Bounds as WindowBounds, PercentBounds } from "../platform/services/window/types"; import { IRouterClient } from "../clients/routerClient"; import { StandardErrorCallback, StandardPromise } from "../types"; export { MonitorInfoDetail } from "../FEA"; export type Bounds = { left: number; top: number; right: number; bottom: number; width: number; height: number; }; declare class Monitors extends EventEmitter { #private; allMonitors: MonitorInfoDetail[]; ready: boolean; constructor(); /** * Use this method to gain access to the Monitors singleton. Never construct * a Monitors class using new. * @returns Singleton instance of Monitors */ static getInstance(): Promise; /** * Initialize the instance. Resolves promise when monitor info has been fetched. * * System events "monitor-info-changed" and "session-changed" will trigger Monitors to refresh its cached monitor info */ initialize(): Promise; /** * Retrieves monitor info from the system and sends an event that docking responds to. * If the number of monitors or id of all monitors hasn't changed, its assumed this * is a scaling/resolution change. The internal state will still be updated and the * returned result will include a 'monitorsChanged' boolean to indicate wether it * has changed or not */ refreshMonitors(): Promise; } /** * Receive a callback whenever the desktop's monitor configuration changes */ export declare const onMonitorsChanged: (cb: (changeData: { monitors: MonitorInfoDetail[]; }) => void) => Promise; /** * Resolves the monitor on which the provided point lie. If the point lies outside of any monitor and the shouldReturnPrimaryDisplayAsDefault is true * then the primary monitor is returned otherwise the null. * * This assumes scaled dimensions for the monitor (For example from electron or WPF directly). */ export declare const getMonitorFromScaledXY: (x: number, y: number, shouldReturnPrimaryDisplayAsDefault?: boolean) => Promise; /** * Retrieves a monitor descriptor for a window. */ export declare const getMonitorFromWindow: (windowDescriptor: WindowDescriptor) => Promise; export type MonitorCommand = "mine" | "primary" | "previous" | "next" | "" | number; /** * This method can be used to retrieve monitor info from the window service. Use this from the client API. */ export declare const getWhichMonitorClientSide: (routerClient: IRouterClient, params?: { monitor?: MonitorCommand; windowIdentifier?: WindowIdentifier; }, cb?: StandardErrorCallback) => StandardPromise; /** * This method can be used to retrieve all monitor info from the window service. Use this from the client API. */ export declare const getAllMonitorsClientSide: (routerClient: IRouterClient, cb?: StandardErrorCallback) => StandardPromise; /** * Gets monitor info for all system monitors. Don't use this in client code. */ export declare const getAllMonitors: () => Promise; /** * Convenience function to get the monitor for the current window * @param {WindowIdentifier} [windowIdentifier] The window to find the monitor for. Current window if empty. */ export declare const getMonitor: (windowIdentifier?: WindowIdentifier) => Promise; /** * Manually initialize Monitors. Used in window service. */ export declare const getMonitorsInstance: () => Promise; /** * Determine if the window's bounds cause it to overlap the docked window. If so, calculate a new position adjacent to the docked window. * Otherwise, the current bounds will be returned * @param monitor - The monitor associated with the moving window. * @param bounds - The location where the moving window is dropped * @param dockedWindowPosition - The edge the toolbar is docked to */ export declare const getBoundsWhenMovedOffDockedWindow: (monitor: MonitorInfoDetail, bounds: Bounds, dockedWindowPosition: string) => { shouldMove: boolean; newBounds: any; }; /** * Converts window bounds to percentage values relative to their position on the monitor. */ export declare const convertBoundsToPercentage: (bounds: WindowBounds, monitorPosition: number) => StandardPromise; /** * Calculate the bumped bounds. These bounds will reflect changes to ensure that the bounds provide enough * for the titlebar to be dragged after a move. For instance, the titlebar may be dragged too low against the Windows * taskbar, precluding movement. In this case, the new bounds will bump the window up slightly so that it can be moved. */ export declare const getBumpedBounds: (monitorsInstance: Monitors | null, bounds: Bounds, rectToUse?: string) => Bounds; /** * Takes a window's bounds and makes sure it's on a monitor. If the window is just off the monitor, bounds will be adjusted to be on the monitor it was on and then the check will occur again. If the window isn't on a monitor (or runs off of a monitor), we determine the closest monitor * based on the distance from the top-left corner of the window to the center of the monitor, and then pull the monitor along that line * until the window is on the edge of the monitor. * * Returns the new bounds for the window. which are different from currentBounds only if the window needs to be relocated */ export declare const adjustBoundsToBeOnMonitor: (monitorsInstance: Monitors | null, bounds: Bounds, rectToUse?: string) => Bounds; /** * Promisified version of adjustBoundsToBeOnMonitor() which doesn't require a monitorsInstance */ export declare const adjustBoundsToBeOnMonitorAsync: (bounds: Bounds, rectToUse?: string) => Promise; /** * Computes the position of the taskbar by analyzing the difference between the monitorRect and availableRect. * * Returns null if there is no taskbar. */ export declare const getTaskbar: (monitor: MonitorInfoDetail) => MonitorTaskbar | null; type BaseMonitor = { rawMonitor?: MonitorInfoDetail | undefined; availableRect: { bottom: number; left: number; right: number; top: number; }; }; /** * Gets the area of the overlap between two rectangles. */ export declare const getOverlap: (rect1: { left: number; right: number; top: number; bottom: number; }, rect2: { left: number; right: number; top: number; bottom: number; }) => number; /** * Given a set of monitors, will return the monitor on which a set of bounds overlaps. * If the window bounds are across more than one monitor then the monitor with the most overlapping surface area with * the window is returned. * * If there is no overlap due to the window being off-monitor it will return the first monitor in the array. */ export declare const getMonitorByBoundsSync: (windowBounds: Bounds, monitors: T[]) => T; export declare const getMonitorByBounds: (windowBounds: Bounds) => Promise; /** * PromiseReturnType is the promisified replacement for ReturnType<>. * Unfortunately there’s no built-in for what is a very useful generic. */ type PromiseReturnType = T extends Promise ? U : T extends (...args: any) => Promise ? U : T extends (...args: any) => infer U ? U : T; type MonitorsType = PromiseReturnType; export { MonitorsType as Monitors }; //# sourceMappingURL=Monitors.d.ts.map