diff --git a/.changes/tray-double-click.md b/.changes/tray-double-click.md new file mode 100644 index 000000000000..af9b54ebe351 --- /dev/null +++ b/.changes/tray-double-click.md @@ -0,0 +1,5 @@ +--- +"tauri": "patch:feat" +--- + +On Windows, Add and emit `DoubleClick` variant for `TrayIconEvent`. diff --git a/Cargo.lock b/Cargo.lock index 2ddabe51b40e..5d629fc7939d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4410,9 +4410,9 @@ dependencies = [ [[package]] name = "tray-icon" -version = "0.15.1" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b92252d649d771105448969f2b2dda4342ba48b77731b60d37c93665e26615b" +checksum = "131a65b2cef2081bc14dbcd414c906edbfa3bb5323dd7e748cc298614681196b" dependencies = [ "core-graphics 0.24.0", "crossbeam-channel", diff --git a/core/tauri/Cargo.toml b/core/tauri/Cargo.toml index ec0e8174e5ec..988b1208d1fa 100644 --- a/core/tauri/Cargo.toml +++ b/core/tauri/Cargo.toml @@ -82,7 +82,7 @@ specta = { version = "^2.0.0-rc.16", optional = true, default-features = false, [target."cfg(any(target_os = \"linux\", target_os = \"dragonfly\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\", target_os = \"windows\", target_os = \"macos\"))".dependencies] muda = { version = "0.14", default-features = false, features = ["serde"] } -tray-icon = { version = "0.15", default-features = false, features = ["serde"], optional = true } +tray-icon = { version = "0.16", default-features = false, features = ["serde"], optional = true } [target."cfg(any(target_os = \"linux\", target_os = \"dragonfly\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\"))".dependencies] gtk = { version = "0.18", features = ["v3_24"] } diff --git a/core/tauri/src/tray/mod.rs b/core/tauri/src/tray/mod.rs index 3363192d8937..53d1589078b7 100644 --- a/core/tauri/src/tray/mod.rs +++ b/core/tauri/src/tray/mod.rs @@ -91,6 +91,17 @@ pub enum TrayIconEvent { /// Mouse button state when this event was triggered. button_state: MouseButtonState, }, + /// A double click happened on the tray icon. **Windows Only** + DoubleClick { + /// Id of the tray icon which triggered this event. + id: TrayIconId, + /// Physical Position of this event. + position: PhysicalPosition, + /// Position and size of the tray icon. + rect: Rect, + /// Mouse button that triggered this event. + button: MouseButton, + }, /// The mouse entered the tray icon region. Enter { /// Id of the tray icon which triggered this event. @@ -125,6 +136,7 @@ impl TrayIconEvent { pub fn id(&self) -> &TrayIconId { match self { TrayIconEvent::Click { id, .. } => id, + TrayIconEvent::DoubleClick { id, .. } => id, TrayIconEvent::Enter { id, .. } => id, TrayIconEvent::Move { id, .. } => id, TrayIconEvent::Leave { id, .. } => id, @@ -151,6 +163,20 @@ impl From for TrayIconEvent { button: button.into(), button_state: button_state.into(), }, + tray_icon::TrayIconEvent::DoubleClick { + id, + position, + rect, + button, + } => TrayIconEvent::DoubleClick { + id, + position, + rect: Rect { + position: rect.position.into(), + size: rect.size.into(), + }, + button: button.into(), + }, tray_icon::TrayIconEvent::Enter { id, position, rect } => TrayIconEvent::Enter { id, position,