1+ // Tray icon implementation for Windows.
2+ //
3+ // Some code reference from:
4+ // https://github.com/tauri-apps/tray-icon/blob/cb22cd5df6b0938aaeebd6c302ec50bc696d8b1a/src/platform_impl/windows/mod.rs
5+
6+ use crate :: * ;
17use image:: EncodableLayout ;
2- use itertools:: Itertools ;
3- ///! Tray icon implementation for Windows.
4- ///
5- ///! Some code reference from:
6- ///! https://github.com/tauri-apps/tray-icon/blob/cb22cd5df6b0938aaeebd6c302ec50bc696d8b1a/src/platform_impl/windows/mod.rs
78use std:: {
8- io:: Read ,
99 mem,
1010 rc:: Rc ,
1111 sync:: {
@@ -21,8 +21,6 @@ use windows::{
2121 core:: * ,
2222} ;
2323
24- use crate :: * ;
25-
2624const PLATFORM_TRAY_CLASS_NAME : PCWSTR = w ! ( "GPUI::PlatformTray" ) ;
2725const WM_USER_TRAYICON : u32 = 6002 ;
2826const WM_USER_UPDATE_TRAYMENU : u32 = 6003 ;
@@ -34,14 +32,14 @@ static WM_TASKBAR_RESTART: LazyLock<u32> =
3432 LazyLock :: new ( || unsafe { RegisterWindowMessageA ( s ! ( "TaskbarCreated" ) ) } ) ;
3533static COUNTER : AtomicU32 = AtomicU32 :: new ( 0 ) ;
3634
37- pub ( super ) struct WindowsTray {
35+ pub ( crate ) struct WindowsTray {
3836 tray_id : u32 ,
3937 hwnd : HWND ,
4038 visible : bool ,
4139}
4240
4341impl WindowsTray {
44- pub ( super ) fn create ( tray : & Tray ) -> Self {
42+ pub ( crate ) fn create ( tray : & Tray ) -> Self {
4543 let tray_id = COUNTER . fetch_add ( 1 , Ordering :: Relaxed ) ;
4644 let mut this = Self {
4745 tray_id,
@@ -52,7 +50,7 @@ impl WindowsTray {
5250 this
5351 }
5452
55- pub ( super ) fn update ( & mut self , tray : & Tray ) {
53+ pub ( crate ) fn update ( & mut self , tray : & Tray ) {
5654 self . set_visible ( tray. visible ) ;
5755 if !self . visible {
5856 return ;
@@ -95,8 +93,8 @@ impl WindowsTray {
9593 let hwnd = result. expect ( "Failed to create tray window" ) ;
9694
9795 if !register_tray_icon ( hwnd, tray_id, None , None ) {
98- let _ = unsafe {
99- DestroyWindow ( hwnd) ;
96+ unsafe {
97+ let _ = DestroyWindow ( hwnd) ;
10098 } ;
10199 return hwnd;
102100 }
@@ -167,8 +165,7 @@ impl WindowsTray {
167165 }
168166 }
169167}
170-
171- pub ( super ) struct TrayUserData {
168+ struct TrayUserData {
172169 hwnd : HWND ,
173170 tray_id : u32 ,
174171 hpopupmenu : Option < HMENU > ,
@@ -327,8 +324,8 @@ unsafe extern "system" fn tray_procedure(
327324
328325fn show_tray_menu ( hwnd : HWND , menu : HMENU , x : i32 , y : i32 ) {
329326 unsafe {
330- SetForegroundWindow ( hwnd) ;
331- TrackPopupMenu (
327+ let _ = SetForegroundWindow ( hwnd) ;
328+ let _ = TrackPopupMenu (
332329 menu,
333330 TPM_BOTTOMALIGN | TPM_LEFTALIGN ,
334331 x,
0 commit comments