feat(core): add set_skip_taskbar API

This commit is contained in:
Lucas Nogueira
2021-05-30 20:48:21 -03:00
parent 5525b03a78
commit e06aa27738
10 changed files with 262 additions and 543 deletions

View File

@@ -0,0 +1,5 @@
---
"api": patch
---
Adds `setSkipTaskbar` to the window API.

View File

@@ -0,0 +1,7 @@
---
"tauri": patch
"tauri-runtime": patch
"tauri-runtime-wry": patch
---
Adds `set_skip_taskbar` API on Window.

View File

@@ -439,6 +439,7 @@ enum WindowMessage {
SetFullscreen(bool),
SetFocus,
SetIcon(WindowIcon),
SetSkipTaskbar(bool),
DragWindow,
}
@@ -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
@@ -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();
}

View File

@@ -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<()>;

File diff suppressed because one or more lines are too long

View File

@@ -74,6 +74,7 @@ pub enum Cmd {
SetIcon {
icon: IconDto,
},
SetSkipTaskbar(bool),
StartDragging,
Print,
}
@@ -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()?,
}

View File

@@ -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)

View File

@@ -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.
*

File diff suppressed because it is too large Load Diff

View File

@@ -25,7 +25,10 @@ describe('[CLI] cli.js template', () => {
const manifestPath = resolve(tauriFixturePath, 'Cargo.toml')
const manifestFile = readFileSync(manifestPath).toString()
writeFileSync(manifestPath, `workspace = { }\n\n${manifestFile}`)
writeFileSync(
manifestPath,
`workspace = { }\n[patch.crates-io]\ntao = { git = "https://github.com/tauri-apps/tao", rev = "a3f533232df25dc30998809094ed5431b449489c" }\n\n${manifestFile}`
)
const { promise: buildPromise } = await build({
config: {