From 4f30ff875bfc556a2a69bf45218129cd196e5105 Mon Sep 17 00:00:00 2001 From: Vincent Povirk Date: Tue, 18 May 2010 13:36:36 -0500 Subject: [PATCH] wineboot: Query windows from all desktops when --end-session --kill is used. --- programs/wineboot/shutdown.c | 39 ++++++++++++++++++++++++++++++++++++ programs/wineboot/wineboot.c | 7 ++++++- 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/programs/wineboot/shutdown.c b/programs/wineboot/shutdown.c index ed80bf03477..cebe16bcd20 100644 --- a/programs/wineboot/shutdown.c +++ b/programs/wineboot/shutdown.c @@ -322,6 +322,45 @@ BOOL shutdown_close_windows( BOOL force ) return (result != 0); } +static BOOL CALLBACK shutdown_one_desktop( LPWSTR name, LPARAM force ) +{ + HDESK hdesk; + + WINE_TRACE("Shutting down desktop %s\n", wine_dbgstr_w(name)); + + hdesk = OpenDesktopW( name, 0, FALSE, GENERIC_ALL ); + if (hdesk == NULL) + { + WINE_ERR("Cannot open desktop %s, err=%i\n", wine_dbgstr_w(name), GetLastError()); + return 0; + } + + if (!SetThreadDesktop( hdesk )) + { + CloseDesktop( hdesk ); + WINE_ERR("Cannot set thread desktop %s, err=%i\n", wine_dbgstr_w(name), GetLastError()); + return 0; + } + + CloseDesktop( hdesk ); + + return shutdown_close_windows( force ); +} + +BOOL shutdown_all_desktops( BOOL force ) +{ + BOOL ret; + HDESK prev_desktop; + + prev_desktop = GetThreadDesktop(GetCurrentThreadId()); + + ret = EnumDesktopsW( NULL, shutdown_one_desktop, (LPARAM)force ); + + SetThreadDesktop(prev_desktop); + + return ret; +} + /* forcibly kill all processes without any cleanup */ void kill_processes( BOOL kill_desktop ) { diff --git a/programs/wineboot/wineboot.c b/programs/wineboot/wineboot.c index 32ac3acb3d3..02d37464b3a 100644 --- a/programs/wineboot/wineboot.c +++ b/programs/wineboot/wineboot.c @@ -88,6 +88,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(wineboot); #define MAX_LINE_LENGTH (2*MAX_PATH+2) extern BOOL shutdown_close_windows( BOOL force ); +extern BOOL shutdown_all_desktops( BOOL force ); extern void kill_processes( BOOL kill_desktop ); static WCHAR windowsdir[MAX_PATH]; @@ -1142,7 +1143,11 @@ int main( int argc, char *argv[] ) if (end_session) { - if (!shutdown_close_windows( force )) return 1; + if (kill) + { + if (!shutdown_all_desktops( force )) return 1; + } + else if (!shutdown_close_windows( force )) return 1; } if (kill) kill_processes( shutdown );