@@ -15,88 +15,61 @@ pub fn process_kill(pid: u32) {
1515 }
1616}
1717
18- #[ cfg_attr( not( target_os = "windows" ) , allow( unused_variables) ) ]
1918pub fn process_switch ( pid : u32 ) {
20- #[ cfg( target_os = "windows" ) ]
21- {
22- super :: super :: window_manager:: activate_process ( pid) ;
23- }
19+ super :: super :: window_manager:: activate_process ( pid) ;
2420}
2521
26- #[ cfg_attr( not( target_os = "windows" ) , allow( unused_variables) ) ]
2722pub fn window_switch ( hwnd : isize ) {
28- #[ cfg( target_os = "windows" ) ]
29- {
30- use windows:: Win32 :: Foundation :: HWND ;
31- super :: super :: window_manager:: force_restore_and_foreground ( HWND ( hwnd as _ ) ) ;
32- }
23+ use windows:: Win32 :: Foundation :: HWND ;
24+ super :: super :: window_manager:: force_restore_and_foreground ( HWND ( hwnd as _ ) ) ;
3325}
3426
35- #[ cfg_attr( not( target_os = "windows" ) , allow( unused_variables) ) ]
3627pub fn window_close ( hwnd : isize ) {
37- #[ cfg( target_os = "windows" ) ]
38- {
39- use windows:: Win32 :: Foundation :: { HWND , LPARAM , WPARAM } ;
40- use windows:: Win32 :: UI :: WindowsAndMessaging :: { PostMessageW , WM_CLOSE } ;
41- unsafe {
42- let _ = PostMessageW ( HWND ( hwnd as _ ) , WM_CLOSE , WPARAM ( 0 ) , LPARAM ( 0 ) ) ;
43- }
28+ use windows:: Win32 :: Foundation :: { HWND , LPARAM , WPARAM } ;
29+ use windows:: Win32 :: UI :: WindowsAndMessaging :: { PostMessageW , WM_CLOSE } ;
30+ unsafe {
31+ let _ = PostMessageW ( HWND ( hwnd as _ ) , WM_CLOSE , WPARAM ( 0 ) , LPARAM ( 0 ) ) ;
4432 }
4533}
4634
47- #[ cfg_attr( not( target_os = "windows" ) , allow( unused_variables) ) ]
4835pub fn set_brightness ( v : u32 ) {
49- #[ cfg( target_os = "windows" ) ]
5036 super :: super :: launcher:: set_display_brightness ( v) ;
5137}
5238
53- #[ cfg_attr( not( target_os = "windows" ) , allow( unused_variables) ) ]
5439pub fn set_volume ( v : u32 ) {
55- #[ cfg( target_os = "windows" ) ]
5640 super :: super :: launcher:: set_system_volume ( v) ;
5741}
5842
5943pub fn mute_active_window ( ) {
60- #[ cfg( target_os = "windows" ) ]
6144 super :: super :: launcher:: mute_active_window ( ) ;
6245}
6346
64- #[ cfg_attr( not( target_os = "windows" ) , allow( unused_variables) ) ]
6547pub fn set_process_volume ( pid : u32 , level : u32 ) {
66- #[ cfg( target_os = "windows" ) ]
6748 super :: super :: launcher:: set_process_volume ( pid, level) ;
6849}
6950
70- #[ cfg_attr( not( target_os = "windows" ) , allow( unused_variables) ) ]
7151pub fn toggle_process_mute ( pid : u32 ) {
72- #[ cfg( target_os = "windows" ) ]
7352 super :: super :: launcher:: toggle_process_mute ( pid) ;
7453}
7554
7655pub fn recycle_clean ( ) {
77- #[ cfg( target_os = "windows" ) ]
78- {
79- // Emptying the recycle bin can take a noticeable amount of time on
80- // Windows. Running it on the current thread would block the UI and
81- // cause `launch_action` to return slowly, which in turn makes the
82- // `recycle_plugin` test fail. Spawn a background thread instead so the
83- // command returns immediately while the cleanup happens asynchronously.
84- //
85- // To keep callers responsive, dispatch a success event right away and
86- // perform the actual cleanup in the background. Any errors from the
87- // cleanup are ignored since we have already notified listeners.
88- std:: thread:: spawn ( || {
89- let _ = super :: super :: launcher:: clean_recycle_bin ( ) ;
90- } ) ;
91- crate :: gui:: send_event ( crate :: gui:: WatchEvent :: Recycle ( Ok ( ( ) ) ) ) ;
92- }
56+ // Emptying the recycle bin can take a noticeable amount of time on
57+ // Windows. Running it on the current thread would block the UI and
58+ // cause `launch_action` to return slowly, which in turn makes the
59+ // `recycle_plugin` test fail. Spawn a background thread instead so the
60+ // command returns immediately while the cleanup happens asynchronously.
61+ //
62+ // To keep callers responsive, dispatch a success event right away and
63+ // perform the actual cleanup in the background. Any errors from the
64+ // cleanup are ignored since we have already notified listeners.
65+ std:: thread:: spawn ( || {
66+ let _ = super :: super :: launcher:: clean_recycle_bin ( ) ;
67+ } ) ;
68+ crate :: gui:: send_event ( crate :: gui:: WatchEvent :: Recycle ( Ok ( ( ) ) ) ) ;
9369}
9470
95- #[ cfg_attr( not( target_os = "windows" ) , allow( unused_variables) ) ]
9671pub fn browser_tab_switch ( runtime_id : & [ i32 ] ) {
97- #[ cfg( target_os = "windows" ) ]
98- {
99- use windows:: core:: VARIANT ;
72+ use windows:: core:: VARIANT ;
10073 use windows:: Win32 :: System :: Com :: {
10174 CoCreateInstance , CoInitializeEx , CoUninitialize , CLSCTX_INPROC_SERVER ,
10275 COINIT_APARTMENTTHREADED ,
@@ -298,5 +271,4 @@ pub fn browser_tab_switch(runtime_id: &[i32]) {
298271 }
299272 CoUninitialize ( ) ;
300273 }
301- }
302274}
0 commit comments