@@ -17,14 +17,15 @@ use windows_sys::{
1717 NIM_ADD , NIM_DELETE , NIM_MODIFY , NOTIFYICONDATAW , NOTIFYICONIDENTIFIER ,
1818 } ,
1919 WindowsAndMessaging :: {
20- CreateWindowExW , DefWindowProcW , DestroyWindow , FindWindowW , GetCursorPos ,
21- KillTimer , RegisterClassW , RegisterWindowMessageA , SendMessageW ,
22- SetForegroundWindow , SetTimer , TrackPopupMenu , CREATESTRUCTW , CW_USEDEFAULT ,
23- GWL_USERDATA , HICON , HMENU , TPM_BOTTOMALIGN , TPM_LEFTALIGN , WM_CREATE , WM_DESTROY ,
24- WM_LBUTTONDBLCLK , WM_LBUTTONDOWN , WM_LBUTTONUP , WM_MBUTTONDBLCLK , WM_MBUTTONDOWN ,
25- WM_MBUTTONUP , WM_MOUSEMOVE , WM_NCCREATE , WM_RBUTTONDBLCLK , WM_RBUTTONDOWN ,
26- WM_RBUTTONUP , WM_TIMER , WNDCLASSW , WS_EX_LAYERED , WS_EX_NOACTIVATE ,
27- WS_EX_TOOLWINDOW , WS_EX_TRANSPARENT , WS_OVERLAPPED ,
20+ ChangeWindowMessageFilterEx , CreateWindowExW , DefWindowProcW , DestroyWindow ,
21+ FindWindowW , GetCursorPos , KillTimer , RegisterClassW , RegisterWindowMessageA ,
22+ SendMessageW , SetForegroundWindow , SetTimer , TrackPopupMenu , CREATESTRUCTW ,
23+ CW_USEDEFAULT , GWL_USERDATA , HICON , HMENU , MSGFLT_ALLOW , TPM_BOTTOMALIGN ,
24+ TPM_LEFTALIGN , WM_CREATE , WM_DESTROY , WM_LBUTTONDBLCLK , WM_LBUTTONDOWN ,
25+ WM_LBUTTONUP , WM_MBUTTONDBLCLK , WM_MBUTTONDOWN , WM_MBUTTONUP , WM_MOUSEMOVE ,
26+ WM_NCCREATE , WM_RBUTTONDBLCLK , WM_RBUTTONDOWN , WM_RBUTTONUP , WM_TIMER , WNDCLASSW ,
27+ WS_EX_LAYERED , WS_EX_NOACTIVATE , WS_EX_TOOLWINDOW , WS_EX_TRANSPARENT ,
28+ WS_OVERLAPPED ,
2829 } ,
2930 } ,
3031 } ,
@@ -127,6 +128,8 @@ impl TrayIcon {
127128 return Err ( crate :: Error :: OsError ( std:: io:: Error :: last_os_error ( ) ) ) ;
128129 }
129130
131+ allow_taskbar_restart_message ( hwnd) ;
132+
130133 let hicon = attrs. icon . as_ref ( ) . map ( |i| i. inner . as_raw_handle ( ) ) ;
131134
132135 let registered = register_tray_icon ( hwnd, internal_id, & hicon, & attrs. tooltip ) ;
@@ -546,6 +549,12 @@ fn taskbar_window_exists() -> bool {
546549 !unsafe { FindWindowW ( class_name. as_ptr ( ) , ptr:: null ( ) ) } . is_null ( )
547550}
548551
552+ #[ inline]
553+ unsafe fn allow_taskbar_restart_message ( hwnd : HWND ) {
554+ // Allow TaskbarCreated to cross UIPI for elevated windows.
555+ let _ = ChangeWindowMessageFilterEx ( hwnd, * S_U_TASKBAR_RESTART , MSGFLT_ALLOW , ptr:: null_mut ( ) ) ;
556+ }
557+
549558#[ inline]
550559unsafe fn register_tray_icon (
551560 hwnd : HWND ,
0 commit comments