Skip to content

Commit

Permalink
feat(core): add set_skip_taskbar API
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog committed May 31, 2021
1 parent 5525b03 commit e06aa27
Show file tree
Hide file tree
Showing 10 changed files with 262 additions and 543 deletions.
5 changes: 5 additions & 0 deletions .changes/api-set-skip-taskbar.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"api": patch
---

Adds `setSkipTaskbar` to the window API.
7 changes: 7 additions & 0 deletions .changes/set-skip-taskbar.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"tauri": patch
"tauri-runtime": patch
"tauri-runtime-wry": patch
---

Adds `set_skip_taskbar` API on Window.
15 changes: 15 additions & 0 deletions core/tauri-runtime-wry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ enum WindowMessage {
SetFullscreen(bool),
SetFocus,
SetIcon(WindowIcon),
SetSkipTaskbar(bool),
DragWindow,
}

Expand Down Expand Up @@ -801,6 +802,17 @@ impl Dispatch for WryDispatcher {
.map_err(|_| Error::FailedToSendMessage)
}

fn set_skip_taskbar(&self, skip: bool) -> Result<()> {
self
.context
.proxy
.send_event(Message::Window(
self.window_id,
WindowMessage::SetSkipTaskbar(skip),
))
.map_err(|_| Error::FailedToSendMessage)
}

fn start_dragging(&self) -> Result<()> {
self
.context
Expand Down Expand Up @@ -1227,6 +1239,9 @@ fn handle_event_loop(
WindowMessage::SetIcon(icon) => {
window.set_window_icon(Some(icon));
}
WindowMessage::SetSkipTaskbar(skip) => {
window.set_skip_taskbar(skip);
}
WindowMessage::DragWindow => {
let _ = window.drag_window();
}
Expand Down
3 changes: 3 additions & 0 deletions core/tauri-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,9 @@ pub trait Dispatch: Clone + Send + Sized + 'static {
/// Updates the window icon.
fn set_icon(&self, icon: Icon) -> crate::Result<()>;

/// Whether to show the window icon in the task bar or not.
fn set_skip_taskbar(&self, skip: bool) -> crate::Result<()>;

/// Starts dragging the window.
fn start_dragging(&self) -> crate::Result<()>;

Expand Down
2 changes: 1 addition & 1 deletion core/tauri/scripts/bundle.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions core/tauri/src/endpoints/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ pub enum Cmd {
SetIcon {
icon: IconDto,
},
SetSkipTaskbar(bool),
StartDragging,
Print,
}
Expand Down Expand Up @@ -158,6 +159,7 @@ impl Cmd {
Self::SetFullscreen(fullscreen) => window.set_fullscreen(fullscreen)?,
Self::SetFocus => window.set_focus()?,
Self::SetIcon { icon } => window.set_icon(icon.into())?,
Self::SetSkipTaskbar(skip) => window.set_skip_taskbar(skip)?,
Self::StartDragging => window.start_dragging()?,
Self::Print => window.print()?,
}
Expand Down
9 changes: 9 additions & 0 deletions core/tauri/src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,15 @@ impl<P: Params> Window<P> {
self.window.dispatcher.set_icon(icon).map_err(Into::into)
}

/// Whether to show the window icon in the task bar or not.
pub fn set_skip_taskbar(&self, skip: bool) -> crate::Result<()> {
self
.window
.dispatcher
.set_skip_taskbar(skip)
.map_err(Into::into)
}

/// Starts dragging the window.
pub fn start_dragging(&self) -> crate::Result<()> {
self.window.dispatcher.start_dragging().map_err(Into::into)
Expand Down
16 changes: 16 additions & 0 deletions tooling/api/src/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,22 @@ class WindowManager {
})
}

/**
* Whether to show the window icon in the task bar or not.
*
* @param skip true to hide window icon, false to show it.
* @returns A promise indicating the success or failure of the operation.
*/
async setSkipTaskbar(skip: boolean): Promise<void> {
return invokeTauriCommand({
__tauriModule: 'Window',
message: {
cmd: 'setSkipTaskbar',
data: skip
}
})
}

/**
* Starts dragging the window.
*
Expand Down
Loading

0 comments on commit e06aa27

Please sign in to comment.