mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-04-01 10:01:07 +02:00
feat(core): add set_skip_taskbar API
This commit is contained in:
5
.changes/api-set-skip-taskbar.md
Normal file
5
.changes/api-set-skip-taskbar.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"api": patch
|
||||
---
|
||||
|
||||
Adds `setSkipTaskbar` to the window API.
|
||||
7
.changes/set-skip-taskbar.md
Normal file
7
.changes/set-skip-taskbar.md
Normal file
@@ -0,0 +1,7 @@
|
||||
---
|
||||
"tauri": patch
|
||||
"tauri-runtime": patch
|
||||
"tauri-runtime-wry": patch
|
||||
---
|
||||
|
||||
Adds `set_skip_taskbar` API on Window.
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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
@@ -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()?,
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
@@ -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: {
|
||||
|
||||
Reference in New Issue
Block a user