Skip to content

Commit 5525b03

Browse files
committed
feat(core): add skip_taskbar API to the WindowBuilder/WindowOptions
1 parent 36506c9 commit 5525b03

File tree

8 files changed

+54
-39
lines changed

8 files changed

+54
-39
lines changed

.changes/api-skip-taskbar.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"api": patch
3+
---
4+
5+
Adds `skipTaskbar?: boolean` to the WindowOptions interface.

.changes/skip-taskbar.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"tauri": patch
3+
"tauri-runtime": patch
4+
"tauri-runtime-wry": patch
5+
---
6+
7+
Adds `skip_taskbar` API to the WindowBuilder.

core/tauri-runtime-wry/src/lib.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,8 @@ impl WindowBuilder for WindowBuilderWrapper {
248248
.maximized(config.maximized)
249249
.fullscreen(config.fullscreen)
250250
.transparent(config.transparent)
251-
.always_on_top(config.always_on_top);
251+
.always_on_top(config.always_on_top)
252+
.skip_taskbar(config.skip_taskbar);
252253

253254
if let (Some(min_width), Some(min_height)) = (config.min_width, config.min_height) {
254255
window = window.min_inner_size(min_width, min_height);
@@ -260,6 +261,10 @@ impl WindowBuilder for WindowBuilderWrapper {
260261
window = window.position(x, y);
261262
}
262263

264+
if config.focus {
265+
window = window.focus();
266+
}
267+
263268
window
264269
}
265270

@@ -355,6 +360,10 @@ impl WindowBuilder for WindowBuilderWrapper {
355360
))
356361
}
357362

363+
fn skip_taskbar(self, skip: bool) -> Self {
364+
Self(self.0.with_skip_taskbar(skip))
365+
}
366+
358367
fn has_icon(&self) -> bool {
359368
self.0.window.window_icon.is_some()
360369
}

core/tauri-runtime/src/webview.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ pub trait WindowBuilder: WindowBuilderBase {
146146
/// Sets the window icon.
147147
fn icon(self, icon: Icon) -> crate::Result<Self>;
148148

149+
/// Sets whether or not the window icon should be added to the taskbar.
150+
fn skip_taskbar(self, skip: bool) -> Self;
151+
149152
/// Sets a parent to the window to be created.
150153
///
151154
/// A child window has the WS_CHILD style and is confined to the client area of its parent window.

core/tauri-utils/src/config.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ pub struct WindowConfig {
8787
/// Whether the window should always be on top of other windows.
8888
#[serde(default)]
8989
pub always_on_top: bool,
90+
/// Whether or not the window icon should be added to the taskbar.
91+
#[serde(default)]
92+
pub skip_taskbar: bool,
9093
}
9194

9295
fn default_window_label() -> String {
@@ -139,6 +142,7 @@ impl Default for WindowConfig {
139142
visible: default_visible(),
140143
decorations: default_decorations(),
141144
always_on_top: false,
145+
skip_taskbar: false,
142146
}
143147
}
144148
}
@@ -640,6 +644,7 @@ mod build {
640644
let visible = self.visible;
641645
let decorations = self.decorations;
642646
let always_on_top = self.always_on_top;
647+
let skip_taskbar = self.skip_taskbar;
643648

644649
literal_struct!(
645650
tokens,
@@ -662,7 +667,8 @@ mod build {
662667
maximized,
663668
visible,
664669
decorations,
665-
always_on_top
670+
always_on_top,
671+
skip_taskbar
666672
);
667673
}
668674
}
@@ -911,6 +917,7 @@ mod test {
911917
visible: true,
912918
decorations: true,
913919
always_on_top: false,
920+
skip_taskbar: false,
914921
}],
915922
bundle: BundleConfig {
916923
identifier: String::from(""),

examples/api/src-tauri/src/main.rs

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -41,27 +41,23 @@ fn main() {
4141
SystemTrayMenuItem::Custom(CustomMenuItem::new("toggle".into(), "Toggle")),
4242
SystemTrayMenuItem::Custom(CustomMenuItem::new("new".into(), "New window")),
4343
])
44-
.on_system_tray_event(|app, event| {
45-
match event.menu_item_id().as_str() {
46-
"toggle" => {
47-
let window = app.get_window("main").unwrap();
48-
if window.is_visible().unwrap() {
49-
window.hide().unwrap();
50-
} else {
51-
window.show().unwrap();
52-
}
44+
.on_system_tray_event(|app, event| match event.menu_item_id().as_str() {
45+
"toggle" => {
46+
let window = app.get_window("main").unwrap();
47+
if window.is_visible().unwrap() {
48+
window.hide().unwrap();
49+
} else {
50+
window.show().unwrap();
5351
}
54-
"new" => app
55-
.create_window(
56-
"new".into(),
57-
WindowUrl::App("index.html".into()),
58-
|window_builder, webview_attributes| {
59-
(window_builder.title("Tauri"), webview_attributes)
60-
},
61-
)
62-
.unwrap(),
63-
_ => {}
6452
}
53+
"new" => app
54+
.create_window(
55+
"new".into(),
56+
WindowUrl::App("index.html".into()),
57+
|window_builder, webview_attributes| (window_builder.title("Tauri"), webview_attributes),
58+
)
59+
.unwrap(),
60+
_ => {}
6561
})
6662
.invoke_handler(tauri::generate_handler![
6763
cmd::log_operation,

tooling/api/src/window.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -803,6 +803,8 @@ interface WindowOptions {
803803
decorations?: boolean
804804
/** Whether the window should always be on top of other windows or not. */
805805
alwaysOnTop?: boolean
806+
/** Whether or not the window icon should be added to the taskbar. */
807+
skipTaskbar?: boolean
806808
}
807809

808810
/**

tooling/cli.rs/Cargo.lock

Lines changed: 4 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)