Merge remote-tracking branch 'origin/v2' into feat/disable-window-buttons

pull/406/head
Lucas Nogueira 2 years ago
commit 185975c876
No known key found for this signature in database
GPG Key ID: 7C32FCA95C8C95D7

@ -0,0 +1,6 @@
---
"window": "minor:feat"
"window-js": "minor:feat"
---
Add `WebviewWindow.is_focused` and `WebviewWindow.getFocusedWindow` getters.

@ -1,4 +1,4 @@
# App ![plugin-app](banner.png)
This plugin provides APIs to read application metadata and macOS app visibility functions. This plugin provides APIs to read application metadata and macOS app visibility functions.

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

@ -1,4 +1,4 @@
# CLI ![plugin-cli](banner.png)
Parse arguments from your Command Line Interface. Parse arguments from your Command Line Interface.

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

@ -1,4 +1,4 @@
# Clipboard Manager ![plugin-clipboard-manager](banner.png)
Read and write to the system clipboard. Read and write to the system clipboard.

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

@ -1,4 +1,4 @@
# Dialog ![plugin-dialog](banner.png)
Native system dialogs for opening and saving files along with message dialogs. Native system dialogs for opening and saving files along with message dialogs.

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

@ -1,4 +1,4 @@
# File System ![plugin-fs](banner.png)
Access the file system. Access the file system.

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

@ -1,4 +1,4 @@
# Global Shortcut ![plugin-global-shortcut](banner.png)
Register global shortcuts. Register global shortcuts.

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

@ -1,4 +1,4 @@
# HTTP ![plugin-http](banner.png)
Access the HTTP client written in Rust. Access the HTTP client written in Rust.

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

@ -1,4 +1,4 @@
# Notification ![plugin-notification](banner.png)
Send message notifications (brief auto-expiring OS window element) to your user. Can also be used with the Notification Web API. Send message notifications (brief auto-expiring OS window element) to your user. Can also be used with the Notification Web API.

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

@ -1,4 +1,4 @@
# Operating System ![plugin-os](banner.png)
Read information about the operating system. Read information about the operating system.

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

@ -1,4 +1,4 @@
# Process ![plugin-process](banner.png)
This plugin provides APIs to access the current process. To spawn child processes, see the [`shell`](https://github.com/tauri-apps/tauri-plugin-shell) plugin. This plugin provides APIs to access the current process. To spawn child processes, see the [`shell`](https://github.com/tauri-apps/tauri-plugin-shell) plugin.

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

@ -1,4 +1,4 @@
# Shell ![plugin-shell](banner.png)
Access the system shell. Allows you to spawn child processes and manage files and URLs using their default application. Access the system shell. Allows you to spawn child processes and manage files and URLs using their default application.

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

@ -1,4 +1,4 @@
# Updater ![plugin-updater](banner.png)
In-app updates for Tauri applications. In-app updates for Tauri applications.

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

@ -1,4 +1,4 @@
# Window ![plugin-window](banner.png)
Interact with the Tauri window. Interact with the Tauri window.

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

@ -563,6 +563,24 @@ class WindowManager extends WebviewWindowHandle {
}); });
} }
/**
* Gets the window's current focus state.
* @example
* ```typescript
* import { appWindow } from '@tauri-apps/plugin-window';
* const focused = await appWindow.isFocused();
* ```
*
* @returns Whether the window is focused or not.
*
* @since 2.0.0
* */
async isFocused(): Promise<boolean> {
return window.__TAURI_INVOKE__("plugin:window|is_focused", {
label: this.label,
});
}
/** /**
* Gets the window's current decorated state. * Gets the window's current decorated state.
* @example * @example
@ -1914,6 +1932,27 @@ class WebviewWindow extends WindowManager {
} }
return null; return null;
} }
/**
* Gets the focused window.
* @example
* ```typescript
* import { WebviewWindow } from '@tauri-apps/plugin-window';
* const focusedWindow = WebviewWindow.getFocusedWindow();
* ```
*
* @returns The WebviewWindow instance to communicate with the webview or `undefined` if there is not any focused window.
*
* @since 1.4
*/
static async getFocusedWindow(): Promise<WebviewWindow | null> {
for (const w of getAll()) {
if (await w.isFocused()) {
return w;
}
}
return null;
}
} }
/** The WebviewWindow for the current window. */ /** The WebviewWindow for the current window. */

File diff suppressed because one or more lines are too long

@ -112,6 +112,7 @@ getter!(outer_size, PhysicalSize<u32>);
getter!(is_fullscreen, bool); getter!(is_fullscreen, bool);
getter!(is_minimized, bool); getter!(is_minimized, bool);
getter!(is_maximized, bool); getter!(is_maximized, bool);
getter!(is_focused, bool);
getter!(is_decorated, bool); getter!(is_decorated, bool);
getter!(is_resizable, bool); getter!(is_resizable, bool);
getter!(is_maximizable, bool); getter!(is_maximizable, bool);

@ -40,6 +40,7 @@ pub fn init<R: Runtime>() -> TauriPlugin<R> {
desktop_commands::is_fullscreen, desktop_commands::is_fullscreen,
desktop_commands::is_minimized, desktop_commands::is_minimized,
desktop_commands::is_maximized, desktop_commands::is_maximized,
desktop_commands::is_focused,
desktop_commands::is_decorated, desktop_commands::is_decorated,
desktop_commands::is_resizable, desktop_commands::is_resizable,
desktop_commands::is_maximizable, desktop_commands::is_maximizable,

Loading…
Cancel
Save