@@ -31,30 +31,37 @@ pub const TRAY_ID: &str = "tray";
3131pub fn create_tray ( app : AppHandle ) {
3232 let menu = create_menu ( & app, "Hide" ) ;
3333
34- #[ allow( clippy:: single_match) ]
35- TrayIconBuilder :: with_id ( TRAY_ID )
34+ let builder = TrayIconBuilder :: with_id ( TRAY_ID )
3635 . icon ( app. default_window_icon ( ) . unwrap ( ) . clone ( ) )
3736 . menu ( & menu)
3837 . show_menu_on_left_click ( false )
39- . on_tray_icon_event ( |tray, event| {
40- match event {
41- TrayIconEvent :: Click {
42- button : MouseButton :: Left ,
43- button_state : MouseButtonState :: Up ,
44- ..
45- } => {
46- #[ cfg( not( target_os = "macos" ) ) ]
47- toggle_main_window (
48- tray. app_handle ( ) ,
49- tray. app_handle ( ) . get_webview_window ( "main" ) ,
50- ) ;
51- }
52- _ => { }
53- } ;
54- } )
55- . on_menu_event ( on_menu_event)
56- . build ( & app)
57- . ok ( ) ;
38+ . on_menu_event ( on_menu_event) ;
39+
40+ #[ allow( clippy:: single_match) ]
41+ let builder = builder. on_tray_icon_event ( |tray, event| {
42+ match event {
43+ TrayIconEvent :: Click {
44+ button : MouseButton :: Left ,
45+ button_state : MouseButtonState :: Up ,
46+ ..
47+ } => {
48+ #[ cfg( not( target_os = "macos" ) ) ]
49+ toggle_main_window (
50+ tray. app_handle ( ) ,
51+ tray. app_handle ( ) . get_webview_window ( "main" ) ,
52+ ) ;
53+ }
54+ _ => { }
55+ } ;
56+ } ) ;
57+
58+ #[ cfg( target_os = "linux" ) ]
59+ let builder = builder. temp_dir_path ( dirs:: runtime_dir ( )
60+ . unwrap_or_else ( std:: env:: temp_dir)
61+ . join ( "tray-icon" )
62+ . join ( & app. config ( ) . identifier ) ) ;
63+
64+ builder. build ( & app) . ok ( ) ;
5865}
5966
6067fn create_menu < R > ( app : & AppHandle < R > , showhide_text : & str ) -> tauri:: menu:: Menu < R >
0 commit comments