mirror of
https://github.com/tauri-apps/tauri.git
synced 2024-11-28 12:27:16 +03:00
feat(core): add skip_taskbar
API to the WindowBuilder/WindowOptions
This commit is contained in:
parent
36506c967d
commit
5525b03a78
5
.changes/api-skip-taskbar.md
Normal file
5
.changes/api-skip-taskbar.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
"api": patch
|
||||
---
|
||||
|
||||
Adds `skipTaskbar?: boolean` to the WindowOptions interface.
|
7
.changes/skip-taskbar.md
Normal file
7
.changes/skip-taskbar.md
Normal file
@ -0,0 +1,7 @@
|
||||
---
|
||||
"tauri": patch
|
||||
"tauri-runtime": patch
|
||||
"tauri-runtime-wry": patch
|
||||
---
|
||||
|
||||
Adds `skip_taskbar` API to the WindowBuilder.
|
@ -248,7 +248,8 @@ impl WindowBuilder for WindowBuilderWrapper {
|
||||
.maximized(config.maximized)
|
||||
.fullscreen(config.fullscreen)
|
||||
.transparent(config.transparent)
|
||||
.always_on_top(config.always_on_top);
|
||||
.always_on_top(config.always_on_top)
|
||||
.skip_taskbar(config.skip_taskbar);
|
||||
|
||||
if let (Some(min_width), Some(min_height)) = (config.min_width, config.min_height) {
|
||||
window = window.min_inner_size(min_width, min_height);
|
||||
@ -260,6 +261,10 @@ impl WindowBuilder for WindowBuilderWrapper {
|
||||
window = window.position(x, y);
|
||||
}
|
||||
|
||||
if config.focus {
|
||||
window = window.focus();
|
||||
}
|
||||
|
||||
window
|
||||
}
|
||||
|
||||
@ -355,6 +360,10 @@ impl WindowBuilder for WindowBuilderWrapper {
|
||||
))
|
||||
}
|
||||
|
||||
fn skip_taskbar(self, skip: bool) -> Self {
|
||||
Self(self.0.with_skip_taskbar(skip))
|
||||
}
|
||||
|
||||
fn has_icon(&self) -> bool {
|
||||
self.0.window.window_icon.is_some()
|
||||
}
|
||||
|
@ -146,6 +146,9 @@ pub trait WindowBuilder: WindowBuilderBase {
|
||||
/// Sets the window icon.
|
||||
fn icon(self, icon: Icon) -> crate::Result<Self>;
|
||||
|
||||
/// Sets whether or not the window icon should be added to the taskbar.
|
||||
fn skip_taskbar(self, skip: bool) -> Self;
|
||||
|
||||
/// Sets a parent to the window to be created.
|
||||
///
|
||||
/// A child window has the WS_CHILD style and is confined to the client area of its parent window.
|
||||
|
@ -87,6 +87,9 @@ pub struct WindowConfig {
|
||||
/// Whether the window should always be on top of other windows.
|
||||
#[serde(default)]
|
||||
pub always_on_top: bool,
|
||||
/// Whether or not the window icon should be added to the taskbar.
|
||||
#[serde(default)]
|
||||
pub skip_taskbar: bool,
|
||||
}
|
||||
|
||||
fn default_window_label() -> String {
|
||||
@ -139,6 +142,7 @@ impl Default for WindowConfig {
|
||||
visible: default_visible(),
|
||||
decorations: default_decorations(),
|
||||
always_on_top: false,
|
||||
skip_taskbar: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -640,6 +644,7 @@ mod build {
|
||||
let visible = self.visible;
|
||||
let decorations = self.decorations;
|
||||
let always_on_top = self.always_on_top;
|
||||
let skip_taskbar = self.skip_taskbar;
|
||||
|
||||
literal_struct!(
|
||||
tokens,
|
||||
@ -662,7 +667,8 @@ mod build {
|
||||
maximized,
|
||||
visible,
|
||||
decorations,
|
||||
always_on_top
|
||||
always_on_top,
|
||||
skip_taskbar
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -911,6 +917,7 @@ mod test {
|
||||
visible: true,
|
||||
decorations: true,
|
||||
always_on_top: false,
|
||||
skip_taskbar: false,
|
||||
}],
|
||||
bundle: BundleConfig {
|
||||
identifier: String::from(""),
|
||||
|
@ -41,27 +41,23 @@ fn main() {
|
||||
SystemTrayMenuItem::Custom(CustomMenuItem::new("toggle".into(), "Toggle")),
|
||||
SystemTrayMenuItem::Custom(CustomMenuItem::new("new".into(), "New window")),
|
||||
])
|
||||
.on_system_tray_event(|app, event| {
|
||||
match event.menu_item_id().as_str() {
|
||||
"toggle" => {
|
||||
let window = app.get_window("main").unwrap();
|
||||
if window.is_visible().unwrap() {
|
||||
window.hide().unwrap();
|
||||
} else {
|
||||
window.show().unwrap();
|
||||
}
|
||||
.on_system_tray_event(|app, event| match event.menu_item_id().as_str() {
|
||||
"toggle" => {
|
||||
let window = app.get_window("main").unwrap();
|
||||
if window.is_visible().unwrap() {
|
||||
window.hide().unwrap();
|
||||
} else {
|
||||
window.show().unwrap();
|
||||
}
|
||||
"new" => app
|
||||
.create_window(
|
||||
"new".into(),
|
||||
WindowUrl::App("index.html".into()),
|
||||
|window_builder, webview_attributes| {
|
||||
(window_builder.title("Tauri"), webview_attributes)
|
||||
},
|
||||
)
|
||||
.unwrap(),
|
||||
_ => {}
|
||||
}
|
||||
"new" => app
|
||||
.create_window(
|
||||
"new".into(),
|
||||
WindowUrl::App("index.html".into()),
|
||||
|window_builder, webview_attributes| (window_builder.title("Tauri"), webview_attributes),
|
||||
)
|
||||
.unwrap(),
|
||||
_ => {}
|
||||
})
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
cmd::log_operation,
|
||||
|
@ -803,6 +803,8 @@ interface WindowOptions {
|
||||
decorations?: boolean
|
||||
/** Whether the window should always be on top of other windows or not. */
|
||||
alwaysOnTop?: boolean
|
||||
/** Whether or not the window icon should be added to the taskbar. */
|
||||
skipTaskbar?: boolean
|
||||
}
|
||||
|
||||
/**
|
||||
|
22
tooling/cli.rs/Cargo.lock
generated
22
tooling/cli.rs/Cargo.lock
generated
@ -629,20 +629,6 @@ version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
|
||||
|
||||
[[package]]
|
||||
name = "handlebars"
|
||||
version = "3.5.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4498fc115fa7d34de968184e473529abb40eeb6be8bc5f7faba3d08c316cb3e3"
|
||||
dependencies = [
|
||||
"log",
|
||||
"pest",
|
||||
"pest_derive",
|
||||
"quick-error",
|
||||
"serde",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "handlebars"
|
||||
version = "4.0.0"
|
||||
@ -1904,7 +1890,7 @@ dependencies = [
|
||||
"chrono",
|
||||
"dirs-next",
|
||||
"glob",
|
||||
"handlebars 3.5.5",
|
||||
"handlebars",
|
||||
"hex",
|
||||
"icns",
|
||||
"image",
|
||||
@ -1935,7 +1921,7 @@ dependencies = [
|
||||
"clap",
|
||||
"colored",
|
||||
"encode_unicode",
|
||||
"handlebars 4.0.0",
|
||||
"handlebars",
|
||||
"heck",
|
||||
"include_dir",
|
||||
"json-patch",
|
||||
@ -2419,9 +2405,9 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
|
||||
[[package]]
|
||||
name = "winreg"
|
||||
version = "0.8.0"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d107f8c6e916235c4c01cabb3e8acf7bea8ef6a63ca2e7fa0527c049badfc48c"
|
||||
checksum = "16cdb3898397cf7f624c294948669beafaeebc5577d5ec53d0afb76633593597"
|
||||
dependencies = [
|
||||
"winapi 0.3.9",
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user