Skip to content

Commit a2fc3a6

Browse files
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>
1 parent e1eb911 commit a2fc3a6

11 files changed

Lines changed: 81 additions & 4 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@tauri-apps/api': 'patch:feat'
3+
'tauri': 'patch:feat'
4+
---
5+
6+
Add `visibleOnAllWorkspaces` option when creating the window in JS and `Window.setVisibleOnAllWorkspaces` method.

core/tauri-config-schema/schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@
487487
"type": "boolean"
488488
},
489489
"visibleOnAllWorkspaces": {
490-
"description": "Whether the window should be visible on all workspaces or virtual desktops.",
490+
"description": "Whether the window should be visible on all workspaces or virtual desktops.\n\n## Platform-specific\n\n- **Windows / iOS / Android:** Unsupported.",
491491
"default": false,
492492
"type": "boolean"
493493
},

core/tauri-utils/src/config.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1189,7 +1189,11 @@ pub struct WindowConfig {
11891189
#[serde(default, alias = "always-on-top")]
11901190
pub always_on_top: bool,
11911191
/// Whether the window should be visible on all workspaces or virtual desktops.
1192-
#[serde(default, alias = "all-workspaces")]
1192+
///
1193+
/// ## Platform-specific
1194+
///
1195+
/// - **Windows / iOS / Android:** Unsupported.
1196+
#[serde(default, alias = "visible-on-all-workspaces")]
11931197
pub visible_on_all_workspaces: bool,
11941198
/// Prevents the window contents from being captured by other apps.
11951199
#[serde(default, alias = "content-protected")]

core/tauri/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ const PLUGINS: &[(&str, &[(&str, bool)])] = &[
7979
("set_effects", false),
8080
("set_always_on_top", false),
8181
("set_always_on_bottom", false),
82+
("set_visible_on_all_workspaces", false),
8283
("set_content_protected", false),
8384
("set_size", false),
8485
("set_min_size", false),
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copyright 2019-2023 Tauri Programme within The Commons Conservancy
2+
# SPDX-License-Identifier: Apache-2.0
3+
# SPDX-License-Identifier: MIT
4+
# Automatically generated - DO NOT EDIT!
5+
6+
"$schema" = "../../../schemas/schema.json"
7+
8+
[[permission]]
9+
identifier = "allow-set-visible-on-all-workspaces"
10+
description = "Enables the set_visible_on_all_workspaces command without any pre-configured scope."
11+
commands.allow = ["set_visible_on_all_workspaces"]
12+
13+
[[permission]]
14+
identifier = "deny-set-visible-on-all-workspaces"
15+
description = "Denies the set_visible_on_all_workspaces command without any pre-configured scope."
16+
commands.deny = ["set_visible_on_all_workspaces"]

core/tauri/permissions/window/schemas/schema.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -988,6 +988,20 @@
988988
"deny-set-title"
989989
]
990990
},
991+
{
992+
"description": "allow-set-visible-on-all-workspaces -> Enables the set_visible_on_all_workspaces command without any pre-configured scope.",
993+
"type": "string",
994+
"enum": [
995+
"allow-set-visible-on-all-workspaces"
996+
]
997+
},
998+
{
999+
"description": "deny-set-visible-on-all-workspaces -> Denies the set_visible_on_all_workspaces command without any pre-configured scope.",
1000+
"type": "string",
1001+
"enum": [
1002+
"deny-set-visible-on-all-workspaces"
1003+
]
1004+
},
9911005
{
9921006
"description": "allow-show -> Enables the show command without any pre-configured scope.",
9931007
"type": "string",

core/tauri/scripts/bundle.global.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/tauri/src/window/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,10 @@ impl<'a, R: Runtime, M: Manager<R>> WindowBuilder<'a, R, M> {
597597
}
598598

599599
/// Whether the window will be visible on all workspaces or virtual desktops.
600+
///
601+
/// ## Platform-specific
602+
///
603+
/// - **Windows / iOS / Android:** Unsupported.
600604
#[must_use]
601605
pub fn visible_on_all_workspaces(mut self, visible_on_all_workspaces: bool) -> Self {
602606
self.window_builder = self
@@ -1659,6 +1663,10 @@ tauri::Builder::default()
16591663
}
16601664

16611665
/// Sets whether the window should be visible on all workspaces or virtual desktops.
1666+
///
1667+
/// ## Platform-specific
1668+
///
1669+
/// - **Windows / iOS / Android:** Unsupported.
16621670
pub fn set_visible_on_all_workspaces(
16631671
&self,
16641672
visible_on_all_workspaces: bool,

core/tauri/src/window/plugin.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ mod desktop_commands {
163163
setter!(start_dragging);
164164
setter!(start_resize_dragging, ResizeDirection);
165165
setter!(set_progress_bar, ProgressBarState);
166+
setter!(set_visible_on_all_workspaces, bool);
166167

167168
#[command(root = "crate")]
168169
pub async fn set_icon<R: Runtime>(
@@ -415,6 +416,7 @@ pub fn init<R: Runtime>() -> TauriPlugin<R> {
415416
desktop_commands::start_resize_dragging,
416417
desktop_commands::set_progress_bar,
417418
desktop_commands::set_icon,
419+
desktop_commands::set_visible_on_all_workspaces,
418420
desktop_commands::toggle_maximize,
419421
desktop_commands::internal_toggle_maximize,
420422
desktop_commands::internal_on_mousemove,

tooling/api/src/window.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1562,6 +1562,22 @@ class Window {
15621562
})
15631563
}
15641564

1565+
/**
1566+
* Sets whether the window should be visible on all workspaces or virtual desktops.
1567+
*
1568+
* ## Platform-specific
1569+
*
1570+
* - **Windows / iOS / Android:** Unsupported.
1571+
*
1572+
* @since 2.0.0
1573+
*/
1574+
async setVisibleOnAllWorkspaces(visible: boolean): Promise<void> {
1575+
return invoke('plugin:window|set_visible_on_all_workspaces', {
1576+
label: this.label,
1577+
value: visible
1578+
})
1579+
}
1580+
15651581
// Listeners
15661582

15671583
/**
@@ -2016,6 +2032,16 @@ interface WindowOptions {
20162032
* Whether the window's native close button is enabled or not. Defaults to `true`.
20172033
*/
20182034
closable?: boolean
2035+
/**
2036+
* Whether the window should be visible on all workspaces or virtual desktops.
2037+
*
2038+
* ## Platform-specific
2039+
*
2040+
* - **Windows / iOS / Android:** Unsupported.
2041+
*
2042+
* @since 2.0.0
2043+
*/
2044+
visibleOnAllWorkspaces?: boolean
20192045
}
20202046

20212047
function mapMonitor(m: Monitor | null): Monitor | null {

0 commit comments

Comments
 (0)