/// import { EventEmitter } from "events"; import { MonitorInfoDetail, MonitorTaskbar } from "../FEA"; import { WindowIdentifier, WindowDescriptor } from "../services/window/types"; import { ILauncherGroup } from "../services/window/types"; import { IRouterClient } from "../clients/routerClient"; import { StandardErrorCallback, StandardPromise } from "../types"; export { MonitorInfoDetail } from "../FEA"; export declare 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 then the primary monitor is returned. * * This assumes scaled dimensions for the monitor (For example from electron or WPF directly). */ export declare const getMonitorFromScaledXY: (x: number, y: number) => Promise; /** * Retrieves a monitor descriptor for a window. */ export declare const getMonitorFromWindow: (windowDescriptor: WindowDescriptor) => Promise; export declare type MonitorCommand = "mine" | "primary" | "previous" | "next" | "" | number; export declare type GetWhichMonitorParams = { commandMonitor: MonitorCommand; monitors: MonitorInfoDetail[]; launchingMonitorPosition: number; windowIdentifier: WindowIdentifier; activeWindows: ILauncherGroup; }; /** * 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; /** * Gets the monitor given a "command" where command can be "primary", "previous", "next" or a number representing a specific monitor. * * Used specifically by launcher. Don't use this in client code. */ export declare const getWhichMonitor: (params: GetWhichMonitorParams) => Promise; /** * 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; }; /** * 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; /** * PromiseReturnType is the promisified replacement for ReturnType<>. * Unfortunately there’s no built-in for what is a very useful generic. */ declare type PromiseReturnType = T extends Promise ? U : T extends (...args: any) => Promise ? U : T extends (...args: any) => infer U ? U : T; declare type MonitorsType = PromiseReturnType; export { MonitorsType as Monitors }; //# sourceMappingURL=Monitors.d.ts.map