@@ -23,20 +23,21 @@ use windows::Win32::{
2323 EnumWindows , GetCursorPos , GetForegroundWindow , GetWindow , GetWindowLongPtrW ,
2424 GetWindowPlacement , GetWindowTextW , GetWindowThreadProcessId , IsIconic ,
2525 SetForegroundWindow , ShowWindow , GWL_EXSTYLE , GWL_STYLE , GWL_USERDATA , GW_OWNER ,
26- SW_RESTORE , WINDOWPLACEMENT , WS_EX_TOOLWINDOW , WS_ICONIC , WS_VISIBLE ,
26+ SW_RESTORE , WINDOWPLACEMENT , WS_EX_TOOLWINDOW , WS_EX_TOPMOST , WS_ICONIC , WS_VISIBLE ,
2727 } ,
2828 } ,
2929} ;
3030
31- pub fn get_window_state ( hwnd : HWND ) -> ( bool , bool , bool ) {
31+ pub fn get_window_state ( hwnd : HWND ) -> ( bool , bool , bool , bool ) {
3232 let style = unsafe { GetWindowLongPtrW ( hwnd, GWL_STYLE ) } as u32 ;
3333 let exstyle = unsafe { GetWindowLongPtrW ( hwnd, GWL_EXSTYLE ) } as u32 ;
3434
3535 let is_visible = style & WS_VISIBLE . 0 != 0 ;
3636 let is_iconic = style & WS_ICONIC . 0 != 0 ;
3737 let is_tool = exstyle & WS_EX_TOOLWINDOW . 0 != 0 ;
38+ let is_topmost = exstyle & WS_EX_TOPMOST . 0 != 0 ;
3839
39- ( is_visible, is_iconic, is_tool)
40+ ( is_visible, is_iconic, is_tool, is_topmost )
4041}
4142
4243pub fn is_iconic_window ( hwnd : HWND ) -> bool {
@@ -219,10 +220,11 @@ pub fn list_windows(
219220 let mut valid_hwnds = vec ! [ ] ;
220221 let mut owner_hwnds = vec ! [ ] ;
221222 for hwnd in hwnds. iter ( ) . cloned ( ) {
222- let ( is_visible, is_iconic, is_tool) = get_window_state ( hwnd) ;
223+ let ( is_visible, is_iconic, is_tool, is_topmost ) = get_window_state ( hwnd) ;
223224 let ok = is_visible
224225 && ( if ignore_minimal { !is_iconic } else { true } )
225226 && !is_tool
227+ && !is_topmost
226228 && !is_cloaked_window ( hwnd, only_current_desktop)
227229 && !is_small_window ( hwnd) ;
228230 if ok {
0 commit comments