Skip to content

Commit e06aa27

Browse files
committed
feat(core): add set_skip_taskbar API
1 parent 5525b03 commit e06aa27

File tree

10 files changed

+262
-543
lines changed

10 files changed

+262
-543
lines changed

.changes/api-set-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 `setSkipTaskbar` to the window API.

.changes/set-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 `set_skip_taskbar` API on Window.

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,7 @@ enum WindowMessage {
439439
SetFullscreen(bool),
440440
SetFocus,
441441
SetIcon(WindowIcon),
442+
SetSkipTaskbar(bool),
442443
DragWindow,
443444
}
444445

@@ -801,6 +802,17 @@ impl Dispatch for WryDispatcher {
801802
.map_err(|_| Error::FailedToSendMessage)
802803
}
803804

805+
fn set_skip_taskbar(&self, skip: bool) -> Result<()> {
806+
self
807+
.context
808+
.proxy
809+
.send_event(Message::Window(
810+
self.window_id,
811+
WindowMessage::SetSkipTaskbar(skip),
812+
))
813+
.map_err(|_| Error::FailedToSendMessage)
814+
}
815+
804816
fn start_dragging(&self) -> Result<()> {
805817
self
806818
.context
@@ -1227,6 +1239,9 @@ fn handle_event_loop(
12271239
WindowMessage::SetIcon(icon) => {
12281240
window.set_window_icon(Some(icon));
12291241
}
1242+
WindowMessage::SetSkipTaskbar(skip) => {
1243+
window.set_skip_taskbar(skip);
1244+
}
12301245
WindowMessage::DragWindow => {
12311246
let _ = window.drag_window();
12321247
}

core/tauri-runtime/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,9 @@ pub trait Dispatch: Clone + Send + Sized + 'static {
298298
/// Updates the window icon.
299299
fn set_icon(&self, icon: Icon) -> crate::Result<()>;
300300

301+
/// Whether to show the window icon in the task bar or not.
302+
fn set_skip_taskbar(&self, skip: bool) -> crate::Result<()>;
303+
301304
/// Starts dragging the window.
302305
fn start_dragging(&self) -> crate::Result<()>;
303306

core/tauri/scripts/bundle.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/endpoints/window.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ pub enum Cmd {
7474
SetIcon {
7575
icon: IconDto,
7676
},
77+
SetSkipTaskbar(bool),
7778
StartDragging,
7879
Print,
7980
}
@@ -158,6 +159,7 @@ impl Cmd {
158159
Self::SetFullscreen(fullscreen) => window.set_fullscreen(fullscreen)?,
159160
Self::SetFocus => window.set_focus()?,
160161
Self::SetIcon { icon } => window.set_icon(icon.into())?,
162+
Self::SetSkipTaskbar(skip) => window.set_skip_taskbar(skip)?,
161163
Self::StartDragging => window.start_dragging()?,
162164
Self::Print => window.print()?,
163165
}

core/tauri/src/window.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,15 @@ impl<P: Params> Window<P> {
543543
self.window.dispatcher.set_icon(icon).map_err(Into::into)
544544
}
545545

546+
/// Whether to show the window icon in the task bar or not.
547+
pub fn set_skip_taskbar(&self, skip: bool) -> crate::Result<()> {
548+
self
549+
.window
550+
.dispatcher
551+
.set_skip_taskbar(skip)
552+
.map_err(Into::into)
553+
}
554+
546555
/// Starts dragging the window.
547556
pub fn start_dragging(&self) -> crate::Result<()> {
548557
self.window.dispatcher.start_dragging().map_err(Into::into)

tooling/api/src/window.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,22 @@ class WindowManager {
745745
})
746746
}
747747

748+
/**
749+
* Whether to show the window icon in the task bar or not.
750+
*
751+
* @param skip true to hide window icon, false to show it.
752+
* @returns A promise indicating the success or failure of the operation.
753+
*/
754+
async setSkipTaskbar(skip: boolean): Promise<void> {
755+
return invokeTauriCommand({
756+
__tauriModule: 'Window',
757+
message: {
758+
cmd: 'setSkipTaskbar',
759+
data: skip
760+
}
761+
})
762+
}
763+
748764
/**
749765
* Starts dragging the window.
750766
*

0 commit comments

Comments
 (0)