Commit 6edd7722 authored by Francois Gouget's avatar Francois Gouget Committed by Alexandre Julliard

user: Fix ExitWindows().

- Use 0 to get an infinite timeout with SendMessageTimeoutW(). - Use SendMessageTimeoutW() to send the WM_ENDSESSION messages too so we don't get stuck if a process is hung. - Only send WM_ENDSESSION to windows that received a WM_QUERYENDSESSION message. Also better mimick the Windows behavior.
parent ec674449
......@@ -374,23 +374,25 @@ BOOL WINAPI ExitWindowsEx( UINT flags, DWORD reason )
{
HWND *phwnd;
UINT send_flags;
DWORD_PTR result;
/* Send a WM_QUERYENDSESSION message to every window */
DWORD_PTR result=1;
/* Send a WM_QUERYENDSESSION / WM_ENDSESSION message pair to
* each window. Note: it might be better to send all the
* WM_QUERYENDSESSION messages, aggregate the results and then
* send all the WM_ENDSESSION messages with the results but
* that's not what Windows does.
*/
send_flags=(flags & EWX_FORCEIFHUNG) ? SMTO_ABORTIFHUNG : SMTO_NORMAL;
for (phwnd = list; *phwnd; phwnd++)
{
/* Make sure that the window still exists */
if (!IsWindow( *phwnd )) continue;
if (SendMessageTimeoutW( *phwnd, WM_QUERYENDSESSION, 0, 0, send_flags, INFINITE, &result) && !result) break;
}
result = (*phwnd == NULL);
/* Now notify all windows that got a WM_QUERYENDSESSION of the result */
for (phwnd = list; *phwnd; phwnd++)
{
if (!IsWindow( *phwnd )) continue;
SendMessageW( *phwnd, WM_ENDSESSION, result, 0 );
if (SendMessageTimeoutW( *phwnd, WM_QUERYENDSESSION, 0, 0, send_flags, 0, &result))
{
DWORD_PTR dummy;
SendMessageTimeoutW( *phwnd, WM_ENDSESSION, result, 0, send_flags, 0, &dummy );
if (!result) break;
}
}
HeapFree( GetProcessHeap(), 0, list );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment