From fc2bd2324e68b9ff4857c7c4a2d3d64f3ed5cf00 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Wed, 20 Apr 2005 18:53:53 +0000 Subject: [PATCH] Handle posted internal messages directly in PeekMessageW to avoid having to return them to the application. Call NtYieldExecution for nicer behavior when PM_NOYIELD is not specified. --- dlls/user/message.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/dlls/user/message.c b/dlls/user/message.c index a395d186a69..d30e2fd69dc 100644 --- a/dlls/user/message.c +++ b/dlls/user/message.c @@ -2672,15 +2672,26 @@ BOOL WINAPI PeekMessageW( MSG *msg_out, HWND hwnd, UINT first, UINT last, UINT f hwnd = WIN_GetFullHandle( hwnd ); - if (!peek_message( &msg, hwnd, first, last, (flags & PM_REMOVE) ? GET_MSG_REMOVE : 0 )) + for (;;) { - if (!(flags & PM_NOYIELD)) + if (!peek_message( &msg, hwnd, first, last, (flags & PM_REMOVE) ? GET_MSG_REMOVE : 0 )) { - DWORD count; - ReleaseThunkLock(&count); - if (count) RestoreThunkLock(count); + if (!(flags & PM_NOYIELD)) + { + DWORD count; + ReleaseThunkLock(&count); + NtYieldExecution(); + if (count) RestoreThunkLock(count); + } + return FALSE; } - return FALSE; + if (msg.message & 0x80000000) + { + handle_internal_message( msg.hwnd, msg.message, msg.wParam, msg.lParam ); + if (!(flags & PM_REMOVE)) /* have to remove it explicitly */ + peek_message( &msg, msg.hwnd, msg.message, msg.message, GET_MSG_REMOVE ); + } + else break; } if ((queue = QUEUE_Current())) @@ -2863,9 +2874,6 @@ LONG WINAPI DispatchMessageA( const MSG* msg ) msg->message, msg->wParam, GetTickCount() ); } - if (msg->message & 0x80000000) - return handle_internal_message( msg->hwnd, msg->message, msg->wParam, msg->lParam ); - if (!(wndPtr = WIN_GetPtr( msg->hwnd ))) { if (msg->hwnd) SetLastError( ERROR_INVALID_WINDOW_HANDLE ); @@ -2938,9 +2946,6 @@ LONG WINAPI DispatchMessageW( const MSG* msg ) msg->message, msg->wParam, GetTickCount() ); } - if (msg->message & 0x80000000) - return handle_internal_message( msg->hwnd, msg->message, msg->wParam, msg->lParam ); - if (!(wndPtr = WIN_GetPtr( msg->hwnd ))) { if (msg->hwnd) SetLastError( ERROR_INVALID_WINDOW_HANDLE );