diff --git a/.changes/api-skip-taskbar.md b/.changes/api-skip-taskbar.md new file mode 100644 index 00000000000..a37747212b3 --- /dev/null +++ b/.changes/api-skip-taskbar.md @@ -0,0 +1,5 @@ +--- +"api": patch +--- + +Adds `skipTaskbar?: boolean` to the WindowOptions interface. diff --git a/.changes/skip-taskbar.md b/.changes/skip-taskbar.md new file mode 100644 index 00000000000..64e849af25e --- /dev/null +++ b/.changes/skip-taskbar.md @@ -0,0 +1,7 @@ +--- +"tauri": patch +"tauri-runtime": patch +"tauri-runtime-wry": patch +--- + +Adds `skip_taskbar` API to the WindowBuilder. diff --git a/core/tauri-runtime-wry/src/lib.rs b/core/tauri-runtime-wry/src/lib.rs index e39b781b123..47fc3d2cde0 100644 --- a/core/tauri-runtime-wry/src/lib.rs +++ b/core/tauri-runtime-wry/src/lib.rs @@ -248,7 +248,8 @@ impl WindowBuilder for WindowBuilderWrapper { .maximized(config.maximized) .fullscreen(config.fullscreen) .transparent(config.transparent) - .always_on_top(config.always_on_top); + .always_on_top(config.always_on_top) + .skip_taskbar(config.skip_taskbar); if let (Some(min_width), Some(min_height)) = (config.min_width, config.min_height) { window = window.min_inner_size(min_width, min_height); @@ -260,6 +261,10 @@ impl WindowBuilder for WindowBuilderWrapper { window = window.position(x, y); } + if config.focus { + window = window.focus(); + } + window } @@ -355,6 +360,10 @@ impl WindowBuilder for WindowBuilderWrapper { )) } + fn skip_taskbar(self, skip: bool) -> Self { + Self(self.0.with_skip_taskbar(skip)) + } + fn has_icon(&self) -> bool { self.0.window.window_icon.is_some() } diff --git a/core/tauri-runtime/src/webview.rs b/core/tauri-runtime/src/webview.rs index 7246f1bae62..1ce519109e8 100644 --- a/core/tauri-runtime/src/webview.rs +++ b/core/tauri-runtime/src/webview.rs @@ -146,6 +146,9 @@ pub trait WindowBuilder: WindowBuilderBase { /// Sets the window icon. fn icon(self, icon: Icon) -> crate::Result; + /// Sets whether or not the window icon should be added to the taskbar. + fn skip_taskbar(self, skip: bool) -> Self; + /// Sets a parent to the window to be created. /// /// A child window has the WS_CHILD style and is confined to the client area of its parent window. diff --git a/core/tauri-utils/src/config.rs b/core/tauri-utils/src/config.rs index 3014eeb9162..6f385a38cbb 100644 --- a/core/tauri-utils/src/config.rs +++ b/core/tauri-utils/src/config.rs @@ -87,6 +87,9 @@ pub struct WindowConfig { /// Whether the window should always be on top of other windows. #[serde(default)] pub always_on_top: bool, + /// Whether or not the window icon should be added to the taskbar. + #[serde(default)] + pub skip_taskbar: bool, } fn default_window_label() -> String { @@ -139,6 +142,7 @@ impl Default for WindowConfig { visible: default_visible(), decorations: default_decorations(), always_on_top: false, + skip_taskbar: false, } } } @@ -640,6 +644,7 @@ mod build { let visible = self.visible; let decorations = self.decorations; let always_on_top = self.always_on_top; + let skip_taskbar = self.skip_taskbar; literal_struct!( tokens, @@ -662,7 +667,8 @@ mod build { maximized, visible, decorations, - always_on_top + always_on_top, + skip_taskbar ); } } @@ -911,6 +917,7 @@ mod test { visible: true, decorations: true, always_on_top: false, + skip_taskbar: false, }], bundle: BundleConfig { identifier: String::from(""), diff --git a/examples/api/src-tauri/src/main.rs b/examples/api/src-tauri/src/main.rs index 19f88f48a06..0c72b243a50 100644 --- a/examples/api/src-tauri/src/main.rs +++ b/examples/api/src-tauri/src/main.rs @@ -41,27 +41,23 @@ fn main() { SystemTrayMenuItem::Custom(CustomMenuItem::new("toggle".into(), "Toggle")), SystemTrayMenuItem::Custom(CustomMenuItem::new("new".into(), "New window")), ]) - .on_system_tray_event(|app, event| { - match event.menu_item_id().as_str() { - "toggle" => { - let window = app.get_window("main").unwrap(); - if window.is_visible().unwrap() { - window.hide().unwrap(); - } else { - window.show().unwrap(); - } + .on_system_tray_event(|app, event| match event.menu_item_id().as_str() { + "toggle" => { + let window = app.get_window("main").unwrap(); + if window.is_visible().unwrap() { + window.hide().unwrap(); + } else { + window.show().unwrap(); } - "new" => app - .create_window( - "new".into(), - WindowUrl::App("index.html".into()), - |window_builder, webview_attributes| { - (window_builder.title("Tauri"), webview_attributes) - }, - ) - .unwrap(), - _ => {} } + "new" => app + .create_window( + "new".into(), + WindowUrl::App("index.html".into()), + |window_builder, webview_attributes| (window_builder.title("Tauri"), webview_attributes), + ) + .unwrap(), + _ => {} }) .invoke_handler(tauri::generate_handler![ cmd::log_operation, diff --git a/tooling/api/src/window.ts b/tooling/api/src/window.ts index 416093df99e..b3cd43e2e52 100644 --- a/tooling/api/src/window.ts +++ b/tooling/api/src/window.ts @@ -803,6 +803,8 @@ interface WindowOptions { decorations?: boolean /** Whether the window should always be on top of other windows or not. */ alwaysOnTop?: boolean + /** Whether or not the window icon should be added to the taskbar. */ + skipTaskbar?: boolean } /** diff --git a/tooling/cli.rs/Cargo.lock b/tooling/cli.rs/Cargo.lock index fda1cc0bf62..b89a50170a1 100755 --- a/tooling/cli.rs/Cargo.lock +++ b/tooling/cli.rs/Cargo.lock @@ -629,20 +629,6 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" -[[package]] -name = "handlebars" -version = "3.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4498fc115fa7d34de968184e473529abb40eeb6be8bc5f7faba3d08c316cb3e3" -dependencies = [ - "log", - "pest", - "pest_derive", - "quick-error", - "serde", - "serde_json", -] - [[package]] name = "handlebars" version = "4.0.0" @@ -1904,7 +1890,7 @@ dependencies = [ "chrono", "dirs-next", "glob", - "handlebars 3.5.5", + "handlebars", "hex", "icns", "image", @@ -1935,7 +1921,7 @@ dependencies = [ "clap", "colored", "encode_unicode", - "handlebars 4.0.0", + "handlebars", "heck", "include_dir", "json-patch", @@ -2419,9 +2405,9 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "winreg" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d107f8c6e916235c4c01cabb3e8acf7bea8ef6a63ca2e7fa0527c049badfc48c" +checksum = "16cdb3898397cf7f624c294948669beafaeebc5577d5ec53d0afb76633593597" dependencies = [ "winapi 0.3.9", ]