user32: Start checking for driver events more often when the app doesn't consume messages properly.

This commit is contained in:
Alexandre Julliard 2012-12-12 20:17:21 +01:00
parent a283b986c7
commit bd5d5e9776
3 changed files with 15 additions and 1 deletions

View File

@ -3671,6 +3671,16 @@ void WINAPI PostQuitMessage( INT exit_code )
SERVER_END_REQ;
}
/* check for driver events if we detect that the app is not properly consuming messages */
static inline void check_for_driver_events(void)
{
if (get_user_thread_info()->message_count > 200)
{
flush_window_surfaces( FALSE );
USER_Driver->pMsgWaitForMultipleObjectsEx( 0, NULL, 0, QS_ALLINPUT, 0 );
}
else get_user_thread_info()->message_count++;
}
/***********************************************************************
* PeekMessageW (USER32.@)
@ -3680,6 +3690,7 @@ BOOL WINAPI DECLSPEC_HOTPATCH PeekMessageW( MSG *msg_out, HWND hwnd, UINT first,
MSG msg;
USER_CheckNotLock();
check_for_driver_events();
if (!peek_message( &msg, hwnd, first, last, flags, 0 ))
{
@ -3726,6 +3737,7 @@ BOOL WINAPI DECLSPEC_HOTPATCH GetMessageW( MSG *msg, HWND hwnd, UINT first, UINT
unsigned int mask = QS_POSTMESSAGE | QS_SENDMESSAGE; /* Always selected */
USER_CheckNotLock();
check_for_driver_events();
if (first || last)
{

View File

@ -172,7 +172,8 @@ struct wm_char_mapping_data
struct user_thread_info
{
HANDLE server_queue; /* Handle to server-side queue */
DWORD recursion_count; /* SendMessage recursion counter */
WORD recursion_count; /* SendMessage recursion counter */
WORD message_count; /* Get/PeekMessage loop counter */
BOOL hook_unicode; /* Is current hook unicode? */
HHOOK hook; /* Current hook */
struct received_message_info *receive_info; /* Message being currently received */

View File

@ -1126,6 +1126,7 @@ static DWORD wait_message( DWORD count, CONST HANDLE *handles, DWORD timeout, DW
{
DWORD ret = USER_Driver->pMsgWaitForMultipleObjectsEx( count, handles, timeout, mask, flags );
if (ret == WAIT_TIMEOUT && !count && !timeout) NtYieldExecution();
if ((mask & QS_INPUT) == QS_INPUT) get_user_thread_info()->message_count = 0;
return ret;
}