From 4cbae274921fff90e7646d9213199feec6360b0e Mon Sep 17 00:00:00 2001 From: Vincent Povirk Date: Mon, 3 Nov 2008 14:11:59 -0600 Subject: [PATCH] wineboot: shut down windows from all desktops --- programs/wineboot/shutdown.c | 31 ++++++++++++++++++++++++++++--- 1 files changed, 28 insertions(+), 3 deletions(-) diff --git a/programs/wineboot/shutdown.c b/programs/wineboot/shutdown.c index 49c03c2..bffa7a4 100644 --- a/programs/wineboot/shutdown.c +++ b/programs/wineboot/shutdown.c @@ -46,7 +46,7 @@ static struct window_info *windows; static DWORD desktop_pid; /* store a new window; callback for EnumWindows */ -static BOOL CALLBACK enum_proc( HWND hwnd, LPARAM lp ) +static BOOL CALLBACK window_enum_proc( HWND hwnd, LPARAM lp ) { if (win_count >= win_max) { @@ -73,14 +73,39 @@ static int cmp_window( const void *ptr1, const void *ptr2 ) return ret; } -/* build the list of all windows (FIXME: handle multiple desktops) */ +static BOOL CALLBACK desktop_enum_proc( LPWSTR lpszDesktop, LPARAM lParam ) +{ + HDESK desktop = OpenDesktopW( lpszDesktop, 0, FALSE, GENERIC_ALL ); + BOOL ret = TRUE; + if (desktop) + { + ret = EnumDesktopWindows( desktop, window_enum_proc, lParam ); + CloseDesktop( desktop ); + } + return ret; +} + +static BOOL CALLBACK winstation_enum_proc( LPWSTR lpszWindowStation, LPARAM lParam ) +{ + HWINSTA winstation = OpenWindowStationW( lpszWindowStation, FALSE, GENERIC_ALL ); + BOOL ret = TRUE; + if (winstation) + { + ret = EnumDesktopsW( winstation, desktop_enum_proc, lParam ); + CloseWindowStation( winstation ); + } + return ret; +} + +/* build the list of all windows */ static BOOL get_all_windows(void) { win_count = 0; win_max = 16; windows = HeapAlloc( GetProcessHeap(), 0, win_max * sizeof(windows[0]) ); if (!windows) return FALSE; - if (!EnumWindows( enum_proc, 0 )) return FALSE; + if (!EnumWindowStationsW( winstation_enum_proc, 0 )) return FALSE; + /* sort windows by processes */ qsort( windows, win_count, sizeof(windows[0]), cmp_window ); return TRUE; -- 1.5.6.3