From 04fc9640c6a6180ebc708af167ab84e51566b3e9 Mon Sep 17 00:00:00 2001 From: Tunglies <77394545+Tunglies@users.noreply.github.com> Date: Thu, 6 Nov 2025 11:31:15 +0800 Subject: [PATCH] refactor: move handle_window_destroyed function under macOS conditional compilation --- src-tauri/src/lib.rs | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 38c4d951b..746df76c6 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -351,23 +351,21 @@ pub fn run() { }); } - pub const fn handle_window_destroyed() { - #[cfg(target_os = "macos")] - { - use crate::core::hotkey::SystemHotkey; - AsyncHandler::spawn(move || async move { - let _ = hotkey::Hotkey::global().unregister_system_hotkey(SystemHotkey::CmdQ); - let _ = hotkey::Hotkey::global().unregister_system_hotkey(SystemHotkey::CmdW); - let is_enable_global_hotkey = Config::verge() - .await - .latest_arc() - .enable_global_hotkey - .unwrap_or(true); - if !is_enable_global_hotkey { - let _ = hotkey::Hotkey::global().reset(); - } - }); - } + #[cfg(target_os = "macos")] + pub fn handle_window_destroyed() { + use crate::core::hotkey::SystemHotkey; + AsyncHandler::spawn(move || async move { + let _ = hotkey::Hotkey::global().unregister_system_hotkey(SystemHotkey::CmdQ); + let _ = hotkey::Hotkey::global().unregister_system_hotkey(SystemHotkey::CmdW); + let is_enable_global_hotkey = Config::verge() + .await + .latest_arc() + .enable_global_hotkey + .unwrap_or(true); + if !is_enable_global_hotkey { + let _ = hotkey::Hotkey::global().reset(); + } + }); } } @@ -447,6 +445,7 @@ pub fn run() { tauri::WindowEvent::Focused(focused) => { event_handlers::handle_window_focus(focused); } + #[cfg(target_os = "macos")] tauri::WindowEvent::Destroyed => { event_handlers::handle_window_destroyed(); }