|
@@ -9,8 +9,8 @@
|
|
|
*
|
|
|
* Events can be listened to using {@link Window.listen}:
|
|
|
* ```typescript
|
|
|
- * import { getCurrent } from "@tauri-apps/api/window";
|
|
|
- * getCurrent().listen("my-window-event", ({ event, payload }) => { });
|
|
|
+ * import { getCurrentWindow } from "@tauri-apps/api/window";
|
|
|
+ * getCurrentWindow().listen("my-window-event", ({ event, payload }) => { });
|
|
|
* ```
|
|
|
*
|
|
|
* @module
|
|
@@ -199,7 +199,7 @@ export interface ProgressBarState {
|
|
|
*
|
|
|
* @since 1.0.0
|
|
|
*/
|
|
|
-function getCurrent(): Window {
|
|
|
+function getCurrentWindow(): Window {
|
|
|
return new Window(window.__TAURI_INTERNALS__.metadata.currentWindow.label, {
|
|
|
// @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
|
|
|
skip: true
|
|
@@ -211,7 +211,7 @@ function getCurrent(): Window {
|
|
|
*
|
|
|
* @since 1.0.0
|
|
|
*/
|
|
|
-function getAll(): Window[] {
|
|
|
+function getAllWindows(): Window[] {
|
|
|
return window.__TAURI_INTERNALS__.metadata.windows.map(
|
|
|
(w) =>
|
|
|
new Window(w.label, {
|
|
@@ -313,21 +313,21 @@ class Window {
|
|
|
* @returns The Window instance to communicate with the window or null if the window doesn't exist.
|
|
|
*/
|
|
|
static getByLabel(label: string): Window | null {
|
|
|
- return getAll().find((w) => w.label === label) ?? null
|
|
|
+ return getAllWindows().find((w) => w.label === label) ?? null
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Get an instance of `Window` for the current window.
|
|
|
*/
|
|
|
static getCurrent(): Window {
|
|
|
- return getCurrent()
|
|
|
+ return getCurrentWindow()
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Gets a list of instances of `Window` for all available windows.
|
|
|
*/
|
|
|
static getAll(): Window[] {
|
|
|
- return getAll()
|
|
|
+ return getAllWindows()
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -341,7 +341,7 @@ class Window {
|
|
|
* @returns The Window instance or `undefined` if there is not any focused window.
|
|
|
*/
|
|
|
static async getFocusedWindow(): Promise<Window | null> {
|
|
|
- for (const w of getAll()) {
|
|
|
+ for (const w of getAllWindows()) {
|
|
|
if (await w.isFocused()) {
|
|
|
return w
|
|
|
}
|
|
@@ -354,8 +354,8 @@ class Window {
|
|
|
*
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
- * import { getCurrent } from '@tauri-apps/api/window';
|
|
|
- * const unlisten = await getCurrent().listen<string>('state-changed', (event) => {
|
|
|
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
|
+ * const unlisten = await getCurrentWindow().listen<string>('state-changed', (event) => {
|
|
|
* console.log(`Got error: ${payload}`);
|
|
|
* });
|
|
|
*
|
|
@@ -389,8 +389,8 @@ class Window {
|
|
|
*
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
- * import { getCurrent } from '@tauri-apps/api/window';
|
|
|
- * const unlisten = await getCurrent().once<null>('initialized', (event) => {
|
|
|
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
|
+ * const unlisten = await getCurrentWindow().once<null>('initialized', (event) => {
|
|
|
* console.log(`Window initialized!`);
|
|
|
* });
|
|
|
*
|
|
@@ -423,8 +423,8 @@ class Window {
|
|
|
* Emits an event to all {@link EventTarget|targets}.
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
- * import { getCurrent } from '@tauri-apps/api/window';
|
|
|
- * await getCurrent().emit('window-loaded', { loggedIn: true, token: 'authToken' });
|
|
|
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
|
+ * await getCurrentWindow().emit('window-loaded', { loggedIn: true, token: 'authToken' });
|
|
|
* ```
|
|
|
*
|
|
|
* @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
|
|
@@ -450,8 +450,8 @@ class Window {
|
|
|
*
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
- * import { getCurrent } from '@tauri-apps/api/window';
|
|
|
- * await getCurrent().emit('main', 'window-loaded', { loggedIn: true, token: 'authToken' });
|
|
|
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
|
+ * await getCurrentWindow().emit('main', 'window-loaded', { loggedIn: true, token: 'authToken' });
|
|
|
* ```
|
|
|
* @param target Label of the target Window/Webview/WebviewWindow or raw {@link EventTarget} object.
|
|
|
* @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
|
|
@@ -496,8 +496,8 @@ class Window {
|
|
|
* The scale factor that can be used to map physical pixels to logical pixels.
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
- * import { getCurrent } from '@tauri-apps/api/window';
|
|
|
- * const factor = await getCurrent().scaleFactor();
|
|
|
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
|
+ * const factor = await getCurrentWindow().scaleFactor();
|
|
|
* ```
|
|
|
*
|
|
|
* @returns The window's monitor scale factor.
|
|
@@ -512,8 +512,8 @@ class Window {
|
|
|
* The position of the top-left hand corner of the window's client area relative to the top-left hand corner of the desktop.
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
- * import { getCurrent } from '@tauri-apps/api/window';
|
|
|
- * const position = await getCurrent().innerPosition();
|
|
|
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
|
+ * const position = await getCurrentWindow().innerPosition();
|
|
|
* ```
|
|
|
*
|
|
|
* @returns The window's inner position.
|
|
@@ -528,8 +528,8 @@ class Window {
|
|
|
* The position of the top-left hand corner of the window relative to the top-left hand corner of the desktop.
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
- * import { getCurrent } from '@tauri-apps/api/window';
|
|
|
- * const position = await getCurrent().outerPosition();
|
|
|
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
|
+ * const position = await getCurrentWindow().outerPosition();
|
|
|
* ```
|
|
|
*
|
|
|
* @returns The window's outer position.
|
|
@@ -545,8 +545,8 @@ class Window {
|
|
|
* The client area is the content of the window, excluding the title bar and borders.
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
- * import { getCurrent } from '@tauri-apps/api/window';
|
|
|
- * const size = await getCurrent().innerSize();
|
|
|
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
|
+ * const size = await getCurrentWindow().innerSize();
|
|
|
* ```
|
|
|
*
|
|
|
* @returns The window's inner size.
|
|
@@ -565,8 +565,8 @@ class Window {
|
|
|
* These dimensions include the title bar and borders. If you don't want that (and you usually don't), use inner_size instead.
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
- * import { getCurrent } from '@tauri-apps/api/window';
|
|
|
- * const size = await getCurrent().outerSize();
|
|
|
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
|
+ * const size = await getCurrentWindow().outerSize();
|
|
|
* ```
|
|
|
*
|
|
|
* @returns The window's outer size.
|
|
@@ -584,8 +584,8 @@ class Window {
|
|
|
* Gets the window's current fullscreen state.
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
- * import { getCurrent } from '@tauri-apps/api/window';
|
|
|
- * const fullscreen = await getCurrent().isFullscreen();
|
|
|
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
|
+ * const fullscreen = await getCurrentWindow().isFullscreen();
|
|
|
* ```
|
|
|
*
|
|
|
* @returns Whether the window is in fullscreen mode or not.
|
|
@@ -600,8 +600,8 @@ class Window {
|
|
|
* Gets the window's current minimized state.
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
- * import { getCurrent } from '@tauri-apps/api/window';
|
|
|
- * const minimized = await getCurrent().isMinimized();
|
|
|
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
|
+ * const minimized = await getCurrentWindow().isMinimized();
|
|
|
* ```
|
|
|
*/
|
|
|
async isMinimized(): Promise<boolean> {
|
|
@@ -614,8 +614,8 @@ class Window {
|
|
|
* Gets the window's current maximized state.
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
- * import { getCurrent } from '@tauri-apps/api/window';
|
|
|
- * const maximized = await getCurrent().isMaximized();
|
|
|
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
|
+ * const maximized = await getCurrentWindow().isMaximized();
|
|
|
* ```
|
|
|
*
|
|
|
* @returns Whether the window is maximized or not.
|
|
@@ -630,8 +630,8 @@ class Window {
|
|
|
* Gets the window's current focus state.
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
- * import { getCurrent } from '@tauri-apps/api/window';
|
|
|
- * const focused = await getCurrent().isFocused();
|
|
|
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
|
+ * const focused = await getCurrentWindow().isFocused();
|
|
|
* ```
|
|
|
*
|
|
|
* @returns Whether the window is focused or not.
|
|
@@ -646,8 +646,8 @@ class Window {
|
|
|
* Gets the window's current decorated state.
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
- * import { getCurrent } from '@tauri-apps/api/window';
|
|
|
- * const decorated = await getCurrent().isDecorated();
|
|
|
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
|
+ * const decorated = await getCurrentWindow().isDecorated();
|
|
|
* ```
|
|
|
*
|
|
|
* @returns Whether the window is decorated or not.
|
|
@@ -662,8 +662,8 @@ class Window {
|
|
|
* Gets the window's current resizable state.
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
- * import { getCurrent } from '@tauri-apps/api/window';
|
|
|
- * const resizable = await getCurrent().isResizable();
|
|
|
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
|
+ * const resizable = await getCurrentWindow().isResizable();
|
|
|
* ```
|
|
|
*
|
|
|
* @returns Whether the window is resizable or not.
|
|
@@ -683,8 +683,8 @@ class Window {
|
|
|
*
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
- * import { getCurrent } from '@tauri-apps/api/window';
|
|
|
- * const maximizable = await getCurrent().isMaximizable();
|
|
|
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
|
+ * const maximizable = await getCurrentWindow().isMaximizable();
|
|
|
* ```
|
|
|
*
|
|
|
* @returns Whether the window's native maximize button is enabled or not.
|
|
@@ -704,8 +704,8 @@ class Window {
|
|
|
*
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
- * import { getCurrent } from '@tauri-apps/api/window';
|
|
|
- * const minimizable = await getCurrent().isMinimizable();
|
|
|
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
|
+ * const minimizable = await getCurrentWindow().isMinimizable();
|
|
|
* ```
|
|
|
*
|
|
|
* @returns Whether the window's native minimize button is enabled or not.
|
|
@@ -725,8 +725,8 @@ class Window {
|
|
|
*
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
- * import { getCurrent } from '@tauri-apps/api/window';
|
|
|
- * const closable = await getCurrent().isClosable();
|
|
|
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
|
+ * const closable = await getCurrentWindow().isClosable();
|
|
|
* ```
|
|
|
*
|
|
|
* @returns Whether the window's native close button is enabled or not.
|
|
@@ -741,8 +741,8 @@ class Window {
|
|
|
* Gets the window's current visible state.
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
- * import { getCurrent } from '@tauri-apps/api/window';
|
|
|
- * const visible = await getCurrent().isVisible();
|
|
|
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
|
+ * const visible = await getCurrentWindow().isVisible();
|
|
|
* ```
|
|
|
*
|
|
|
* @returns Whether the window is visible or not.
|
|
@@ -757,8 +757,8 @@ class Window {
|
|
|
* Gets the window's current title.
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
- * import { getCurrent } from '@tauri-apps/api/window';
|
|
|
- * const title = await getCurrent().title();
|
|
|
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
|
+ * const title = await getCurrentWindow().title();
|
|
|
* ```
|
|
|
*/
|
|
|
async title(): Promise<string> {
|
|
@@ -776,8 +776,8 @@ class Window {
|
|
|
*
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
- * import { getCurrent } from '@tauri-apps/api/window';
|
|
|
- * const theme = await getCurrent().theme();
|
|
|
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
|
+ * const theme = await getCurrentWindow().theme();
|
|
|
* ```
|
|
|
*
|
|
|
* @returns The window theme.
|
|
@@ -794,8 +794,8 @@ class Window {
|
|
|
* Centers the window.
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
- * import { getCurrent } from '@tauri-apps/api/window';
|
|
|
- * await getCurrent().center();
|
|
|
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
|
+ * await getCurrentWindow().center();
|
|
|
* ```
|
|
|
*
|
|
|
* @returns A promise indicating the success or failure of the operation.
|
|
@@ -820,8 +820,8 @@ class Window {
|
|
|
* - **Linux:** Urgency levels have the same effect.
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
- * import { getCurrent } from '@tauri-apps/api/window';
|
|
|
- * await getCurrent().requestUserAttention();
|
|
|
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
|
+ * await getCurrentWindow().requestUserAttention();
|
|
|
* ```
|
|
|
*
|
|
|
* @returns A promise indicating the success or failure of the operation.
|
|
@@ -848,8 +848,8 @@ class Window {
|
|
|
* Updates the window resizable flag.
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
- * import { getCurrent } from '@tauri-apps/api/window';
|
|
|
- * await getCurrent().setResizable(false);
|
|
|
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
|
+ * await getCurrentWindow().setResizable(false);
|
|
|
* ```
|
|
|
*
|
|
|
* @returns A promise indicating the success or failure of the operation.
|
|
@@ -872,8 +872,8 @@ class Window {
|
|
|
*
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
- * import { getCurrent } from '@tauri-apps/api/window';
|
|
|
- * await getCurrent().setMaximizable(false);
|
|
|
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
|
+ * await getCurrentWindow().setMaximizable(false);
|
|
|
* ```
|
|
|
*
|
|
|
* @returns A promise indicating the success or failure of the operation.
|
|
@@ -894,8 +894,8 @@ class Window {
|
|
|
*
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
- * import { getCurrent } from '@tauri-apps/api/window';
|
|
|
- * await getCurrent().setMinimizable(false);
|
|
|
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
|
+ * await getCurrentWindow().setMinimizable(false);
|
|
|
* ```
|
|
|
*
|
|
|
* @returns A promise indicating the success or failure of the operation.
|
|
@@ -917,8 +917,8 @@ class Window {
|
|
|
*
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
- * import { getCurrent } from '@tauri-apps/api/window';
|
|
|
- * await getCurrent().setClosable(false);
|
|
|
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
|
+ * await getCurrentWindow().setClosable(false);
|
|
|
* ```
|
|
|
*
|
|
|
* @returns A promise indicating the success or failure of the operation.
|
|
@@ -934,8 +934,8 @@ class Window {
|
|
|
* Sets the window title.
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
- * import { getCurrent } from '@tauri-apps/api/window';
|
|
|
- * await getCurrent().setTitle('Tauri');
|
|
|
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
|
+ * await getCurrentWindow().setTitle('Tauri');
|
|
|
* ```
|
|
|
*
|
|
|
* @param title The new title
|
|
@@ -952,8 +952,8 @@ class Window {
|
|
|
* Maximizes the window.
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
- * import { getCurrent } from '@tauri-apps/api/window';
|
|
|
- * await getCurrent().maximize();
|
|
|
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
|
+ * await getCurrentWindow().maximize();
|
|
|
* ```
|
|
|
*
|
|
|
* @returns A promise indicating the success or failure of the operation.
|
|
@@ -968,8 +968,8 @@ class Window {
|
|
|
* Unmaximizes the window.
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
- * import { getCurrent } from '@tauri-apps/api/window';
|
|
|
- * await getCurrent().unmaximize();
|
|
|
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
|
+ * await getCurrentWindow().unmaximize();
|
|
|
* ```
|
|
|
*
|
|
|
* @returns A promise indicating the success or failure of the operation.
|
|
@@ -984,8 +984,8 @@ class Window {
|
|
|
* Toggles the window maximized state.
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
- * import { getCurrent } from '@tauri-apps/api/window';
|
|
|
- * await getCurrent().toggleMaximize();
|
|
|
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
|
+ * await getCurrentWindow().toggleMaximize();
|
|
|
* ```
|
|
|
*
|
|
|
* @returns A promise indicating the success or failure of the operation.
|
|
@@ -1000,8 +1000,8 @@ class Window {
|
|
|
* Minimizes the window.
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
- * import { getCurrent } from '@tauri-apps/api/window';
|
|
|
- * await getCurrent().minimize();
|
|
|
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
|
+ * await getCurrentWindow().minimize();
|
|
|
* ```
|
|
|
*
|
|
|
* @returns A promise indicating the success or failure of the operation.
|
|
@@ -1016,8 +1016,8 @@ class Window {
|
|
|
* Unminimizes the window.
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
- * import { getCurrent } from '@tauri-apps/api/window';
|
|
|
- * await getCurrent().unminimize();
|
|
|
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
|
+ * await getCurrentWindow().unminimize();
|
|
|
* ```
|
|
|
*
|
|
|
* @returns A promise indicating the success or failure of the operation.
|
|
@@ -1032,8 +1032,8 @@ class Window {
|
|
|
* Sets the window visibility to true.
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
- * import { getCurrent } from '@tauri-apps/api/window';
|
|
|
- * await getCurrent().show();
|
|
|
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
|
+ * await getCurrentWindow().show();
|
|
|
* ```
|
|
|
*
|
|
|
* @returns A promise indicating the success or failure of the operation.
|
|
@@ -1048,8 +1048,8 @@ class Window {
|
|
|
* Sets the window visibility to false.
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
- * import { getCurrent } from '@tauri-apps/api/window';
|
|
|
- * await getCurrent().hide();
|
|
|
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
|
+ * await getCurrentWindow().hide();
|
|
|
* ```
|
|
|
*
|
|
|
* @returns A promise indicating the success or failure of the operation.
|
|
@@ -1066,8 +1066,8 @@ class Window {
|
|
|
* Note this emits a closeRequested event so you can intercept it. To force window close, use {@link Window.destroy}.
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
- * import { getCurrent } from '@tauri-apps/api/window';
|
|
|
- * await getCurrent().close();
|
|
|
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
|
+ * await getCurrentWindow().close();
|
|
|
* ```
|
|
|
*
|
|
|
* @returns A promise indicating the success or failure of the operation.
|
|
@@ -1082,8 +1082,8 @@ class Window {
|
|
|
* Destroys the window. Behaves like {@link Window.close} but forces the window close instead of emitting a closeRequested event.
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
- * import { getCurrent } from '@tauri-apps/api/window';
|
|
|
- * await getCurrent().destroy();
|
|
|
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
|
+ * await getCurrentWindow().destroy();
|
|
|
* ```
|
|
|
*
|
|
|
* @returns A promise indicating the success or failure of the operation.
|
|
@@ -1098,8 +1098,8 @@ class Window {
|
|
|
* Whether the window should have borders and bars.
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
- * import { getCurrent } from '@tauri-apps/api/window';
|
|
|
- * await getCurrent().setDecorations(false);
|
|
|
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
|
+ * await getCurrentWindow().setDecorations(false);
|
|
|
* ```
|
|
|
*
|
|
|
* @param decorations Whether the window should have borders and bars.
|
|
@@ -1125,8 +1125,8 @@ class Window {
|
|
|
*
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
- * import { getCurrent } from '@tauri-apps/api/window';
|
|
|
- * await getCurrent().setShadow(false);
|
|
|
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
|
+ * await getCurrentWindow().setShadow(false);
|
|
|
* ```
|
|
|
*
|
|
|
* @returns A promise indicating the success or failure of the operation.
|
|
@@ -1162,8 +1162,8 @@ class Window {
|
|
|
* Whether the window should always be on top of other windows.
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
- * import { getCurrent } from '@tauri-apps/api/window';
|
|
|
- * await getCurrent().setAlwaysOnTop(true);
|
|
|
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
|
+ * await getCurrentWindow().setAlwaysOnTop(true);
|
|
|
* ```
|
|
|
*
|
|
|
* @param alwaysOnTop Whether the window should always be on top of other windows or not.
|
|
@@ -1180,8 +1180,8 @@ class Window {
|
|
|
* Whether the window should always be below other windows.
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
- * import { getCurrent } from '@tauri-apps/api/window';
|
|
|
- * await getCurrent().setAlwaysOnBottom(true);
|
|
|
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
|
+ * await getCurrentWindow().setAlwaysOnBottom(true);
|
|
|
* ```
|
|
|
*
|
|
|
* @param alwaysOnBottom Whether the window should always be below other windows or not.
|
|
@@ -1198,8 +1198,8 @@ class Window {
|
|
|
* Prevents the window contents from being captured by other apps.
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
- * import { getCurrent } from '@tauri-apps/api/window';
|
|
|
- * await getCurrent().setContentProtected(true);
|
|
|
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
|
+ * await getCurrentWindow().setContentProtected(true);
|
|
|
* ```
|
|
|
*
|
|
|
* @returns A promise indicating the success or failure of the operation.
|
|
@@ -1215,8 +1215,8 @@ class Window {
|
|
|
* Resizes the window with a new inner size.
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
- * import { getCurrent, LogicalSize } from '@tauri-apps/api/window';
|
|
|
- * await getCurrent().setSize(new LogicalSize(600, 500));
|
|
|
+ * import { getCurrentWindow, LogicalSize } from '@tauri-apps/api/window';
|
|
|
+ * await getCurrentWindow().setSize(new LogicalSize(600, 500));
|
|
|
* ```
|
|
|
*
|
|
|
* @param size The logical or physical inner size.
|
|
@@ -1245,8 +1245,8 @@ class Window {
|
|
|
* Sets the window minimum inner size. If the `size` argument is not provided, the constraint is unset.
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
- * import { getCurrent, PhysicalSize } from '@tauri-apps/api/window';
|
|
|
- * await getCurrent().setMinSize(new PhysicalSize(600, 500));
|
|
|
+ * import { getCurrentWindow, PhysicalSize } from '@tauri-apps/api/window';
|
|
|
+ * await getCurrentWindow().setMinSize(new PhysicalSize(600, 500));
|
|
|
* ```
|
|
|
*
|
|
|
* @param size The logical or physical inner size, or `null` to unset the constraint.
|
|
@@ -1280,8 +1280,8 @@ class Window {
|
|
|
* Sets the window maximum inner size. If the `size` argument is undefined, the constraint is unset.
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
- * import { getCurrent, LogicalSize } from '@tauri-apps/api/window';
|
|
|
- * await getCurrent().setMaxSize(new LogicalSize(600, 500));
|
|
|
+ * import { getCurrentWindow, LogicalSize } from '@tauri-apps/api/window';
|
|
|
+ * await getCurrentWindow().setMaxSize(new LogicalSize(600, 500));
|
|
|
* ```
|
|
|
*
|
|
|
* @param size The logical or physical inner size, or `null` to unset the constraint.
|
|
@@ -1315,8 +1315,8 @@ class Window {
|
|
|
* Sets the window outer position.
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
- * import { getCurrent, LogicalPosition } from '@tauri-apps/api/window';
|
|
|
- * await getCurrent().setPosition(new LogicalPosition(600, 500));
|
|
|
+ * import { getCurrentWindow, LogicalPosition } from '@tauri-apps/api/window';
|
|
|
+ * await getCurrentWindow().setPosition(new LogicalPosition(600, 500));
|
|
|
* ```
|
|
|
*
|
|
|
* @param position The new position, in logical or physical pixels.
|
|
@@ -1350,8 +1350,8 @@ class Window {
|
|
|
* Sets the window fullscreen state.
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
- * import { getCurrent } from '@tauri-apps/api/window';
|
|
|
- * await getCurrent().setFullscreen(true);
|
|
|
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
|
+ * await getCurrentWindow().setFullscreen(true);
|
|
|
* ```
|
|
|
*
|
|
|
* @param fullscreen Whether the window should go to fullscreen or not.
|
|
@@ -1368,8 +1368,8 @@ class Window {
|
|
|
* Bring the window to front and focus.
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
- * import { getCurrent } from '@tauri-apps/api/window';
|
|
|
- * await getCurrent().setFocus();
|
|
|
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
|
+ * await getCurrentWindow().setFocus();
|
|
|
* ```
|
|
|
*
|
|
|
* @returns A promise indicating the success or failure of the operation.
|
|
@@ -1384,8 +1384,8 @@ class Window {
|
|
|
* Sets the window icon.
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
- * import { getCurrent } from '@tauri-apps/api/window';
|
|
|
- * await getCurrent().setIcon('/tauri/awesome.png');
|
|
|
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
|
+ * await getCurrentWindow().setIcon('/tauri/awesome.png');
|
|
|
* ```
|
|
|
*
|
|
|
* Note that you need the `image-ico` or `image-png` Cargo features to use this API.
|
|
@@ -1415,8 +1415,8 @@ class Window {
|
|
|
* - **macOS:** Unsupported.
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
- * import { getCurrent } from '@tauri-apps/api/window';
|
|
|
- * await getCurrent().setSkipTaskbar(true);
|
|
|
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
|
+ * await getCurrentWindow().setSkipTaskbar(true);
|
|
|
* ```
|
|
|
*
|
|
|
* @param skip true to hide window icon, false to show it.
|
|
@@ -1441,8 +1441,8 @@ class Window {
|
|
|
* - **macOS:** This locks the cursor in a fixed location, which looks visually awkward.
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
- * import { getCurrent } from '@tauri-apps/api/window';
|
|
|
- * await getCurrent().setCursorGrab(true);
|
|
|
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
|
+ * await getCurrentWindow().setCursorGrab(true);
|
|
|
* ```
|
|
|
*
|
|
|
* @param grab `true` to grab the cursor icon, `false` to release it.
|
|
@@ -1465,8 +1465,8 @@ class Window {
|
|
|
* outside of the window.
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
- * import { getCurrent } from '@tauri-apps/api/window';
|
|
|
- * await getCurrent().setCursorVisible(false);
|
|
|
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
|
+ * await getCurrentWindow().setCursorVisible(false);
|
|
|
* ```
|
|
|
*
|
|
|
* @param visible If `false`, this will hide the cursor. If `true`, this will show the cursor.
|
|
@@ -1483,8 +1483,8 @@ class Window {
|
|
|
* Modifies the cursor icon of the window.
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
- * import { getCurrent } from '@tauri-apps/api/window';
|
|
|
- * await getCurrent().setCursorIcon('help');
|
|
|
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
|
+ * await getCurrentWindow().setCursorIcon('help');
|
|
|
* ```
|
|
|
*
|
|
|
* @param icon The new cursor icon.
|
|
@@ -1501,8 +1501,8 @@ class Window {
|
|
|
* Changes the position of the cursor in window coordinates.
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
- * import { getCurrent, LogicalPosition } from '@tauri-apps/api/window';
|
|
|
- * await getCurrent().setCursorPosition(new LogicalPosition(600, 300));
|
|
|
+ * import { getCurrentWindow, LogicalPosition } from '@tauri-apps/api/window';
|
|
|
+ * await getCurrentWindow().setCursorPosition(new LogicalPosition(600, 300));
|
|
|
* ```
|
|
|
*
|
|
|
* @param position The new cursor position.
|
|
@@ -1537,8 +1537,8 @@ class Window {
|
|
|
*
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
- * import { getCurrent } from '@tauri-apps/api/window';
|
|
|
- * await getCurrent().setIgnoreCursorEvents(true);
|
|
|
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
|
+ * await getCurrentWindow().setIgnoreCursorEvents(true);
|
|
|
* ```
|
|
|
*
|
|
|
* @param ignore `true` to ignore the cursor events; `false` to process them as usual.
|
|
@@ -1555,8 +1555,8 @@ class Window {
|
|
|
* Starts dragging the window.
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
- * import { getCurrent } from '@tauri-apps/api/window';
|
|
|
- * await getCurrent().startDragging();
|
|
|
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
|
+ * await getCurrentWindow().startDragging();
|
|
|
* ```
|
|
|
*
|
|
|
* @return A promise indicating the success or failure of the operation.
|
|
@@ -1571,8 +1571,8 @@ class Window {
|
|
|
* Starts resize-dragging the window.
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
- * import { getCurrent } from '@tauri-apps/api/window';
|
|
|
- * await getCurrent().startResizeDragging();
|
|
|
+ * import { getCurrentWindow } from '@tauri-apps/api/window';
|
|
|
+ * await getCurrentWindow().startResizeDragging();
|
|
|
* ```
|
|
|
*
|
|
|
* @return A promise indicating the success or failure of the operation.
|
|
@@ -1594,8 +1594,8 @@ class Window {
|
|
|
*
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
- * import { getCurrent, ProgressBarStatus } from '@tauri-apps/api/window';
|
|
|
- * await getCurrent().setProgressBar({
|
|
|
+ * import { getCurrentWindow, ProgressBarStatus } from '@tauri-apps/api/window';
|
|
|
+ * await getCurrentWindow().setProgressBar({
|
|
|
* status: ProgressBarStatus.Normal,
|
|
|
* progress: 50,
|
|
|
* });
|
|
@@ -1645,8 +1645,8 @@ class Window {
|
|
|
*
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
- * import { getCurrent } from "@tauri-apps/api/window";
|
|
|
- * const unlisten = await getCurrent().onResized(({ payload: size }) => {
|
|
|
+ * import { getCurrentWindow } from "@tauri-apps/api/window";
|
|
|
+ * const unlisten = await getCurrentWindow().onResized(({ payload: size }) => {
|
|
|
* console.log('Window resized', size);
|
|
|
* });
|
|
|
*
|
|
@@ -1669,8 +1669,8 @@ class Window {
|
|
|
*
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
- * import { getCurrent } from "@tauri-apps/api/window";
|
|
|
- * const unlisten = await getCurrent().onMoved(({ payload: position }) => {
|
|
|
+ * import { getCurrentWindow } from "@tauri-apps/api/window";
|
|
|
+ * const unlisten = await getCurrentWindow().onMoved(({ payload: position }) => {
|
|
|
* console.log('Window moved', position);
|
|
|
* });
|
|
|
*
|
|
@@ -1693,9 +1693,9 @@ class Window {
|
|
|
*
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
- * import { getCurrent } from "@tauri-apps/api/window";
|
|
|
+ * import { getCurrentWindow } from "@tauri-apps/api/window";
|
|
|
* import { confirm } from '@tauri-apps/api/dialog';
|
|
|
- * const unlisten = await getCurrent().onCloseRequested(async (event) => {
|
|
|
+ * const unlisten = await getCurrentWindow().onCloseRequested(async (event) => {
|
|
|
* const confirmed = await confirm('Are you sure?');
|
|
|
* if (!confirmed) {
|
|
|
* // user did not confirm closing the window; let's prevent it
|
|
@@ -1730,8 +1730,8 @@ class Window {
|
|
|
*
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
- * import { getCurrent } from "@tauri-apps/api/webview";
|
|
|
- * const unlisten = await getCurrent().onDragDropEvent((event) => {
|
|
|
+ * import { getCurrentWindow } from "@tauri-apps/api/webview";
|
|
|
+ * const unlisten = await getCurrentWindow().onDragDropEvent((event) => {
|
|
|
* if (event.payload.type === 'hover') {
|
|
|
* console.log('User hovering', event.payload.paths);
|
|
|
* } else if (event.payload.type === 'drop') {
|
|
@@ -1812,8 +1812,8 @@ class Window {
|
|
|
*
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
- * import { getCurrent } from "@tauri-apps/api/window";
|
|
|
- * const unlisten = await getCurrent().onFocusChanged(({ payload: focused }) => {
|
|
|
+ * import { getCurrentWindow } from "@tauri-apps/api/window";
|
|
|
+ * const unlisten = await getCurrentWindow().onFocusChanged(({ payload: focused }) => {
|
|
|
* console.log('Focus changed, window is focused? ' + focused);
|
|
|
* });
|
|
|
*
|
|
@@ -1852,8 +1852,8 @@ class Window {
|
|
|
*
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
- * import { getCurrent } from "@tauri-apps/api/window";
|
|
|
- * const unlisten = await getCurrent().onScaleChanged(({ payload }) => {
|
|
|
+ * import { getCurrentWindow } from "@tauri-apps/api/window";
|
|
|
+ * const unlisten = await getCurrentWindow().onScaleChanged(({ payload }) => {
|
|
|
* console.log('Scale changed', payload.scaleFactor, payload.size);
|
|
|
* });
|
|
|
*
|
|
@@ -1878,8 +1878,8 @@ class Window {
|
|
|
*
|
|
|
* @example
|
|
|
* ```typescript
|
|
|
- * import { getCurrent } from "@tauri-apps/api/window";
|
|
|
- * const unlisten = await getCurrent().onThemeChanged(({ payload: theme }) => {
|
|
|
+ * import { getCurrentWindow } from "@tauri-apps/api/window";
|
|
|
+ * const unlisten = await getCurrentWindow().onThemeChanged(({ payload: theme }) => {
|
|
|
* console.log('New theme: ' + theme);
|
|
|
* });
|
|
|
*
|
|
@@ -2304,8 +2304,8 @@ async function cursorPosition(): Promise<PhysicalPosition> {
|
|
|
export {
|
|
|
Window,
|
|
|
CloseRequestedEvent,
|
|
|
- getCurrent,
|
|
|
- getAll,
|
|
|
+ getCurrentWindow,
|
|
|
+ getAllWindows,
|
|
|
LogicalSize,
|
|
|
PhysicalSize,
|
|
|
LogicalPosition,
|