فهرست منبع

feat(api/window): add visible-on-all-workspaces, closes #8652 (#8657)

* feat(api/window): add visible-on-all-worksapces, closes #8652

* fix build and generate schema

* Update .changes/api-set-visible-on-all-workspaces.md

* revert permissions

* fix alias

* revert set_icon change

* add missing permission

---------

Co-authored-by: Lucas Fernandes Nogueira <lucas@tauri.app>
Amr Bashir 1 سال پیش
والد
کامیت
a2fc3a6357

+ 6 - 0
.changes/api-set-visible-on-all-workspaces.md

@@ -0,0 +1,6 @@
+---
+'@tauri-apps/api': 'patch:feat'
+'tauri': 'patch:feat'
+---
+
+Add `visibleOnAllWorkspaces` option when creating the window in JS and `Window.setVisibleOnAllWorkspaces` method.

+ 1 - 1
core/tauri-config-schema/schema.json

@@ -487,7 +487,7 @@
           "type": "boolean"
         },
         "visibleOnAllWorkspaces": {
-          "description": "Whether the window should be visible on all workspaces or virtual desktops.",
+          "description": "Whether the window should be visible on all workspaces or virtual desktops.\n\n## Platform-specific\n\n- **Windows / iOS / Android:** Unsupported.",
           "default": false,
           "type": "boolean"
         },

+ 5 - 1
core/tauri-utils/src/config.rs

@@ -1189,7 +1189,11 @@ pub struct WindowConfig {
   #[serde(default, alias = "always-on-top")]
   pub always_on_top: bool,
   /// Whether the window should be visible on all workspaces or virtual desktops.
-  #[serde(default, alias = "all-workspaces")]
+  ///
+  /// ## Platform-specific
+  ///
+  /// - **Windows / iOS / Android:** Unsupported.
+  #[serde(default, alias = "visible-on-all-workspaces")]
   pub visible_on_all_workspaces: bool,
   /// Prevents the window contents from being captured by other apps.
   #[serde(default, alias = "content-protected")]

+ 1 - 0
core/tauri/build.rs

@@ -79,6 +79,7 @@ const PLUGINS: &[(&str, &[(&str, bool)])] = &[
       ("set_effects", false),
       ("set_always_on_top", false),
       ("set_always_on_bottom", false),
+      ("set_visible_on_all_workspaces", false),
       ("set_content_protected", false),
       ("set_size", false),
       ("set_min_size", false),

+ 16 - 0
core/tauri/permissions/window/autogenerated/commands/set_visible_on_all_workspaces.toml

@@ -0,0 +1,16 @@
+# Copyright 2019-2023 Tauri Programme within The Commons Conservancy
+# SPDX-License-Identifier: Apache-2.0
+# SPDX-License-Identifier: MIT
+# Automatically generated - DO NOT EDIT!
+
+"$schema" = "../../../schemas/schema.json"
+
+[[permission]]
+identifier = "allow-set-visible-on-all-workspaces"
+description = "Enables the set_visible_on_all_workspaces command without any pre-configured scope."
+commands.allow = ["set_visible_on_all_workspaces"]
+
+[[permission]]
+identifier = "deny-set-visible-on-all-workspaces"
+description = "Denies the set_visible_on_all_workspaces command without any pre-configured scope."
+commands.deny = ["set_visible_on_all_workspaces"]

+ 14 - 0
core/tauri/permissions/window/schemas/schema.json

@@ -988,6 +988,20 @@
             "deny-set-title"
           ]
         },
+        {
+          "description": "allow-set-visible-on-all-workspaces -> Enables the set_visible_on_all_workspaces command without any pre-configured scope.",
+          "type": "string",
+          "enum": [
+            "allow-set-visible-on-all-workspaces"
+          ]
+        },
+        {
+          "description": "deny-set-visible-on-all-workspaces -> Denies the set_visible_on_all_workspaces command without any pre-configured scope.",
+          "type": "string",
+          "enum": [
+            "deny-set-visible-on-all-workspaces"
+          ]
+        },
         {
           "description": "allow-show -> Enables the show command without any pre-configured scope.",
           "type": "string",

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 0
core/tauri/scripts/bundle.global.js


+ 8 - 0
core/tauri/src/window/mod.rs

@@ -597,6 +597,10 @@ impl<'a, R: Runtime, M: Manager<R>> WindowBuilder<'a, R, M> {
   }
 
   /// Whether the window will be visible on all workspaces or virtual desktops.
+  ///
+  /// ## Platform-specific
+  ///
+  /// - **Windows / iOS / Android:** Unsupported.
   #[must_use]
   pub fn visible_on_all_workspaces(mut self, visible_on_all_workspaces: bool) -> Self {
     self.window_builder = self
@@ -1659,6 +1663,10 @@ tauri::Builder::default()
   }
 
   /// Sets whether the window should be visible on all workspaces or virtual desktops.
+  ///
+  /// ## Platform-specific
+  ///
+  /// - **Windows / iOS / Android:** Unsupported.
   pub fn set_visible_on_all_workspaces(
     &self,
     visible_on_all_workspaces: bool,

+ 2 - 0
core/tauri/src/window/plugin.rs

@@ -163,6 +163,7 @@ mod desktop_commands {
   setter!(start_dragging);
   setter!(start_resize_dragging, ResizeDirection);
   setter!(set_progress_bar, ProgressBarState);
+  setter!(set_visible_on_all_workspaces, bool);
 
   #[command(root = "crate")]
   pub async fn set_icon<R: Runtime>(
@@ -415,6 +416,7 @@ pub fn init<R: Runtime>() -> TauriPlugin<R> {
             desktop_commands::start_resize_dragging,
             desktop_commands::set_progress_bar,
             desktop_commands::set_icon,
+            desktop_commands::set_visible_on_all_workspaces,
             desktop_commands::toggle_maximize,
             desktop_commands::internal_toggle_maximize,
             desktop_commands::internal_on_mousemove,

+ 26 - 0
tooling/api/src/window.ts

@@ -1562,6 +1562,22 @@ class Window {
     })
   }
 
+  /**
+   * Sets whether the window should be visible on all workspaces or virtual desktops.
+   *
+   * ## Platform-specific
+   *
+   * - **Windows / iOS / Android:** Unsupported.
+   *
+   * @since 2.0.0
+   */
+  async setVisibleOnAllWorkspaces(visible: boolean): Promise<void> {
+    return invoke('plugin:window|set_visible_on_all_workspaces', {
+      label: this.label,
+      value: visible
+    })
+  }
+
   // Listeners
 
   /**
@@ -2016,6 +2032,16 @@ interface WindowOptions {
    * Whether the window's native close button is enabled or not. Defaults to `true`.
    */
   closable?: boolean
+  /**
+   * Whether the window should be visible on all workspaces or virtual desktops.
+   *
+   * ## Platform-specific
+   *
+   * - **Windows / iOS / Android:** Unsupported.
+   *
+   * @since 2.0.0
+   */
+  visibleOnAllWorkspaces?: boolean
 }
 
 function mapMonitor(m: Monitor | null): Monitor | null {

+ 1 - 1
tooling/cli/schema.json

@@ -487,7 +487,7 @@
           "type": "boolean"
         },
         "visibleOnAllWorkspaces": {
-          "description": "Whether the window should be visible on all workspaces or virtual desktops.",
+          "description": "Whether the window should be visible on all workspaces or virtual desktops.\n\n## Platform-specific\n\n- **Windows / iOS / Android:** Unsupported.",
           "default": false,
           "type": "boolean"
         },

برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است