From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/message.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-)
diff --git a/dlls/win32u/message.c b/dlls/win32u/message.c index a51f452bb7c..f3e9f6858de 100644 --- a/dlls/win32u/message.c +++ b/dlls/win32u/message.c @@ -3154,19 +3154,34 @@ static inline LARGE_INTEGER *get_nt_timeout( LARGE_INTEGER *time, DWORD timeout return time; }
+static DWORD wait_multiple_objects_flush( DWORD count, const HANDLE *handles, DWORD timeout, DWORD mask, DWORD flags ) +{ + LARGE_INTEGER time, now, *abs; + DWORD ret; + + NtQuerySystemTime( &now ); + + if ((abs = get_nt_timeout( &time, timeout ))) abs->QuadPart = now.QuadPart - abs->QuadPart; + else time.QuadPart = INT64_MAX; + + do + { + flush_window_surfaces( TRUE ); + now.QuadPart = min( time.QuadPart, now.QuadPart + 333333 /* 30 fps */ ); + ret = NtWaitForMultipleObjects( count, handles, !(flags & MWMO_WAITALL), !!(flags & MWMO_ALERTABLE), &now ); + } while (ret == WAIT_TIMEOUT && now.QuadPart < time.QuadPart); + + return ret; +} + /* wait for message or signaled handle */ static DWORD wait_message( DWORD count, const HANDLE *handles, DWORD timeout, DWORD mask, DWORD flags ) { struct thunk_lock_params params = {.dispatch.callback = thunk_lock_callback}; - LARGE_INTEGER time, now, *abs; DWORD ret = count - 1; void *ret_ptr; ULONG ret_len;
- NtQuerySystemTime( &now ); - - if ((abs = get_nt_timeout( &time, timeout ))) abs->QuadPart = now.QuadPart - abs->QuadPart; - if (!KeUserDispatchCallback( ¶ms.dispatch, sizeof(params), &ret_ptr, &ret_len ) && ret_len == sizeof(params.locks)) { @@ -3177,7 +3192,7 @@ static DWORD wait_message( DWORD count, const HANDLE *handles, DWORD timeout, DW if (user_driver->pProcessEvents( mask )) ret = count - 1; else { - ret = NtWaitForMultipleObjects( count, handles, !(flags & MWMO_WAITALL), !!(flags & MWMO_ALERTABLE), abs ); + ret = wait_multiple_objects_flush( count, handles, timeout, mask, flags ); if (ret == count - 1) user_driver->pProcessEvents( mask ); else if (HIWORD(ret)) /* is it an error code? */ {