@@ -22,7 +22,9 @@ use std::{
2222use windows:: {
2323 core:: { s, BOOL , PCWSTR } ,
2424 Win32 :: {
25- Foundation :: { HANDLE , HINSTANCE , HWND , LPARAM , LRESULT , POINT , RECT , WAIT_TIMEOUT , WPARAM } ,
25+ Foundation :: {
26+ HANDLE , HINSTANCE , HWND , LPARAM , LRESULT , POINT , RECT , TRUE , WAIT_TIMEOUT , WPARAM ,
27+ } ,
2628 Graphics :: Gdi :: * ,
2729 System :: {
2830 LibraryLoader :: GetModuleHandleW ,
@@ -642,15 +644,15 @@ lazy_static! {
642644 RegisterWindowMessageA ( s!( "TaskbarCreated" ) )
643645 } ;
644646 static ref THREAD_EVENT_TARGET_WINDOW_CLASS : Vec <u16 > = unsafe {
645- let class_name= util:: encode_wide( "Tao Thread Event Target" ) ;
647+ let class_name = util:: encode_wide( "Tao Thread Event Target" ) ;
646648
647649 let class = WNDCLASSEXW {
648650 cbSize: mem:: size_of:: <WNDCLASSEXW >( ) as u32 ,
649651 style: Default :: default ( ) ,
650652 lpfnWndProc: Some ( util:: call_default_window_proc) ,
651653 cbClsExtra: 0 ,
652654 cbWndExtra: 0 ,
653- hInstance: HINSTANCE ( GetModuleHandleW ( PCWSTR :: null( ) ) . unwrap_or_default( ) . 0 ) ,
655+ hInstance: HINSTANCE ( GetModuleHandleW ( PCWSTR :: null( ) ) . unwrap_or_default( ) . 0 ) ,
654656 hIcon: HICON :: default ( ) ,
655657 hCursor: HCURSOR :: default ( ) , // must be null in order for cursor state to work properly
656658 hbrBackground: HBRUSH :: default ( ) ,
@@ -2380,6 +2382,18 @@ unsafe extern "system" fn thread_event_target_callback<T: 'static>(
23802382 DefSubclassProc ( window, msg, wparam, lparam)
23812383 }
23822384
2385+ // We don't process `WM_QUERYENDSESSION` yet until we introduce the same mechanism as Tauri's `ExitRequested` event
2386+ // win32wm::WM_QUERYENDSESSION => {}
2387+ win32wm:: WM_ENDSESSION => {
2388+ // `wParam` is `FALSE` is for if the shutdown gets canceled,
2389+ // and we don't need to handle that case since we didn't do anything prior in response to `WM_QUERYENDSESSION`
2390+ if wparam. 0 == TRUE . 0 as usize {
2391+ subclass_input. event_loop_runner . loop_destroyed ( ) ;
2392+ }
2393+ // Note: after we return 0 here, Windows will shut us down
2394+ LRESULT ( 0 )
2395+ }
2396+
23832397 _ if msg == * USER_EVENT_MSG_ID => {
23842398 if let Ok ( event) = subclass_input. user_event_receiver . recv ( ) {
23852399 subclass_input. send_event ( Event :: UserEvent ( event) ) ;
0 commit comments