You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tauri-plugins-workspace/plugins/positioner/guest-js/index.ts

44 lines
934 B

// Copyright 2021 Jonas Kruckenberg
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
declare global {
interface Window {
__TAURI_INVOKE__: <T>(cmd: string, args?: unknown) => Promise<T>;
}
}
/**
* Well known window positions.
*/
export enum Position {
TopLeft = 0,
TopRight,
BottomLeft,
BottomRight,
TopCenter,
BottomCenter,
LeftCenter,
RightCenter,
Center,
TrayLeft,
TrayBottomLeft,
TrayRight,
TrayBottomRight,
TrayCenter,
TrayBottomCenter,
}
/**
* Moves the `Window` to the given {@link Position} using `WindowExt.move_window()`
* All positions are relative to the **current** screen.
*
* @param to The {@link Position} to move to.
*/
export async function moveWindow(to: Position): Promise<void> {
await window.__TAURI_INVOKE__("plugin:positioner|move_window", {
position: to,
});
}