From 25d0ced8ba02f9cdf85d46be9c02654332b55b4f Mon Sep 17 00:00:00 2001 From: 21pages Date: Sun, 30 Jun 2024 13:54:40 +0800 Subject: [PATCH] fix ci (#8543) Signed-off-by: 21pages --- libs/hbb_common/Cargo.toml | 2 +- libs/hbb_common/src/platform/windows.rs | 3 +-- src/tray.rs | 23 ++++++++++++++++------- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/libs/hbb_common/Cargo.toml b/libs/hbb_common/Cargo.toml index 8ae3ebcd5..7aeb43797 100644 --- a/libs/hbb_common/Cargo.toml +++ b/libs/hbb_common/Cargo.toml @@ -58,7 +58,7 @@ tokio-native-tls ="0.3" protobuf-codegen = { version = "3.4" } [target.'cfg(target_os = "windows")'.dependencies] -winapi = { version = "0.3", features = ["winuser", "synchapi", "pdh", "memoryapi"] } +winapi = { version = "0.3", features = ["winuser", "synchapi", "pdh", "memoryapi", "sysinfoapi"] } [target.'cfg(target_os = "macos")'.dependencies] osascript = "0.3" diff --git a/libs/hbb_common/src/platform/windows.rs b/libs/hbb_common/src/platform/windows.rs index c36c384d3..7481631ac 100644 --- a/libs/hbb_common/src/platform/windows.rs +++ b/libs/hbb_common/src/platform/windows.rs @@ -1,6 +1,5 @@ use std::{ collections::VecDeque, - os::windows::raw::HANDLE, sync::{Arc, Mutex}, time::Instant, }; @@ -17,7 +16,7 @@ use winapi::{ sysinfoapi::VerSetConditionMask, winbase::{VerifyVersionInfoW, INFINITE, WAIT_OBJECT_0}, winnt::{ - OSVERSIONINFOEXW, VER_BUILDNUMBER, VER_GREATER_EQUAL, VER_MAJORVERSION, + HANDLE, OSVERSIONINFOEXW, VER_BUILDNUMBER, VER_GREATER_EQUAL, VER_MAJORVERSION, VER_MINORVERSION, VER_SERVICEPACKMAJOR, VER_SERVICEPACKMINOR, }, }, diff --git a/src/tray.rs b/src/tray.rs index 8251d2505..01f91dbdc 100644 --- a/src/tray.rs +++ b/src/tray.rs @@ -137,14 +137,23 @@ pub fn make_tray() -> hbb_common::ResultType<()> { if let Ok(_event) = tray_channel.try_recv() { #[cfg(target_os = "windows")] - if _event.click_type == tray_icon::ClickType::Left - || _event.click_type == tray_icon::ClickType::Double - { - if last_click.elapsed() < std::time::Duration::from_secs(1) { - return; + match _event { + TrayEvent::Click { + button, + button_state, + .. + } => { + if button == tray_icon::MouseButton::Left + && button_state == tray_icon::MouseButtonState::Up + { + if last_click.elapsed() < std::time::Duration::from_secs(1) { + return; + } + open_func(); + last_click = std::time::Instant::now(); + } } - open_func(); - last_click = std::time::Instant::now(); + _ => {} } }