Skip to content

Commit

Permalink
feat: add DoubleClick variant for TrayIconEvent (#10786)
Browse files Browse the repository at this point in the history
* feat: add `DoubleClick` variant for `TrayIconEvent`

* revert api example change

---------

Co-authored-by: Lucas Nogueira <[email protected]>
  • Loading branch information
amrbashir and lucasfernog committed Aug 27, 2024
1 parent 3a4972b commit 1e44181
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changes/tray-double-click.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tauri": "patch:feat"
---

On Windows, Add and emit `DoubleClick` variant for `TrayIconEvent`.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion core/tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
26 changes: 26 additions & 0 deletions core/tauri/src/tray/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<f64>,
/// 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.
Expand Down Expand Up @@ -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,
Expand All @@ -151,6 +163,20 @@ impl From<tray_icon::TrayIconEvent> 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,
Expand Down

0 comments on commit 1e44181

Please sign in to comment.