win32u: Use NT interface for MsgWaitForMultipleObjectsEx user driver entry point.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2022-05-03 13:23:42 +02:00 committed by Alexandre Julliard
parent 365bc308be
commit ac9b635800
11 changed files with 62 additions and 56 deletions

View File

@ -1432,6 +1432,7 @@ static void update_now( HWND hwnd, UINT rdw_flags )
*/
BOOL WINAPI NtUserRedrawWindow( HWND hwnd, const RECT *rect, HRGN hrgn, UINT flags )
{
LARGE_INTEGER zero = { .QuadPart = 0 };
static const RECT empty;
BOOL ret;
@ -1452,7 +1453,7 @@ BOOL WINAPI NtUserRedrawWindow( HWND hwnd, const RECT *rect, HRGN hrgn, UINT fla
}
/* process pending expose events before painting */
if (flags & RDW_UPDATENOW) user_driver->pMsgWaitForMultipleObjectsEx( 0, NULL, 0, QS_PAINT, 0 );
if (flags & RDW_UPDATENOW) user_driver->pMsgWaitForMultipleObjectsEx( 0, NULL, &zero, QS_PAINT, 0 );
if (rect && !hrgn)
{

View File

@ -784,30 +784,14 @@ static void nulldrv_GetDC( HDC hdc, HWND hwnd, HWND top_win, const RECT *win_rec
{
}
/* helper for kernel32->ntdll timeout format conversion */
static inline LARGE_INTEGER *get_nt_timeout( LARGE_INTEGER *time, DWORD timeout )
static NTSTATUS nulldrv_MsgWaitForMultipleObjectsEx( DWORD count, const HANDLE *handles,
const LARGE_INTEGER *timeout,
DWORD mask, DWORD flags )
{
if (timeout == INFINITE) return NULL;
time->QuadPart = (ULONGLONG)timeout * -10000;
return time;
}
if (!count && timeout && !timeout->QuadPart) return WAIT_TIMEOUT;
static DWORD nulldrv_MsgWaitForMultipleObjectsEx( DWORD count, const HANDLE *handles, DWORD timeout,
DWORD mask, DWORD flags )
{
NTSTATUS status;
LARGE_INTEGER time;
if (!count && !timeout) return WAIT_TIMEOUT;
status = NtWaitForMultipleObjects( count, handles, !(flags & MWMO_WAITALL), !!(flags & MWMO_ALERTABLE),
get_nt_timeout( &time, timeout ) );
if (HIWORD(status)) /* is it an error code? */
{
SetLastError( RtlNtStatusToDosError(status) );
status = WAIT_FAILED;
}
return status;
return NtWaitForMultipleObjects( count, handles, !(flags & MWMO_WAITALL),
!!(flags & MWMO_ALERTABLE), timeout );
}
static void nulldrv_ReleaseDC( HWND hwnd, HDC hdc )

View File

@ -268,7 +268,8 @@ BOOL WINAPI NtUserGetCursorInfo( CURSORINFO *info )
static void check_for_events( UINT flags )
{
if (user_driver->pMsgWaitForMultipleObjectsEx( 0, NULL, 0, flags, 0 ) == WAIT_TIMEOUT)
LARGE_INTEGER zero = { .QuadPart = 0 };
if (user_driver->pMsgWaitForMultipleObjectsEx( 0, NULL, &zero, flags, 0 ) == WAIT_TIMEOUT)
flush_window_surfaces( TRUE );
}

View File

@ -1897,8 +1897,9 @@ static inline void check_for_driver_events( UINT msg )
{
if (get_user_thread_info()->message_count > 200)
{
LARGE_INTEGER zero = { .QuadPart = 0 };
flush_window_surfaces( FALSE );
user_driver->pMsgWaitForMultipleObjectsEx( 0, NULL, 0, QS_ALLINPUT, 0 );
user_driver->pMsgWaitForMultipleObjectsEx( 0, NULL, &zero, QS_ALLINPUT, 0 );
}
else if (msg == WM_TIMER || msg == WM_SYSTIMER)
{
@ -1908,9 +1909,18 @@ static inline void check_for_driver_events( UINT msg )
else get_user_thread_info()->message_count++;
}
/* helper for kernel32->ntdll timeout format conversion */
static inline LARGE_INTEGER *get_nt_timeout( LARGE_INTEGER *time, DWORD timeout )
{
if (timeout == INFINITE) return NULL;
time->QuadPart = (ULONGLONG)timeout * -10000;
return time;
}
/* wait for message or signaled handle */
static DWORD wait_message( DWORD count, const HANDLE *handles, DWORD timeout, DWORD mask, DWORD flags )
{
LARGE_INTEGER time;
DWORD ret, lock;
void *ret_ptr;
ULONG ret_len;
@ -1918,7 +1928,13 @@ static DWORD wait_message( DWORD count, const HANDLE *handles, DWORD timeout, DW
if (enable_thunk_lock)
lock = KeUserModeCallback( NtUserThunkLock, NULL, 0, &ret_ptr, &ret_len );
ret = user_driver->pMsgWaitForMultipleObjectsEx( count, handles, timeout, mask, flags );
ret = user_driver->pMsgWaitForMultipleObjectsEx( count, handles, get_nt_timeout( &time, timeout ),
mask, flags );
if (HIWORD(ret)) /* is it an error code? */
{
SetLastError( RtlNtStatusToDosError(ret) );
ret = WAIT_FAILED;
}
if (ret == WAIT_TIMEOUT && !count && !timeout) NtYieldExecution();
if ((mask & QS_INPUT) == QS_INPUT) get_user_thread_info()->message_count = 0;

View File

@ -86,8 +86,9 @@ extern SHORT ANDROID_VkKeyScanEx( WCHAR ch, HKL hkl ) DECLSPEC_HIDDEN;
extern void ANDROID_SetCursor( HCURSOR handle ) DECLSPEC_HIDDEN;
extern BOOL ANDROID_CreateWindow( HWND hwnd ) DECLSPEC_HIDDEN;
extern void ANDROID_DestroyWindow( HWND hwnd ) DECLSPEC_HIDDEN;
extern DWORD ANDROID_MsgWaitForMultipleObjectsEx( DWORD count, const HANDLE *handles, DWORD timeout,
DWORD mask, DWORD flags ) DECLSPEC_HIDDEN;
extern NTSTATUS ANDROID_MsgWaitForMultipleObjectsEx( DWORD count, const HANDLE *handles,
const LARGE_INTEGER *timeout,
DWORD mask, DWORD flags ) DECLSPEC_HIDDEN;
extern void ANDROID_SetCursor( HCURSOR handle ) DECLSPEC_HIDDEN;
extern void ANDROID_SetLayeredWindowAttributes( HWND hwnd, COLORREF key, BYTE alpha,
DWORD flags ) DECLSPEC_HIDDEN;

View File

@ -1201,8 +1201,9 @@ static LRESULT CALLBACK desktop_wndproc_wrapper( HWND hwnd, UINT msg, WPARAM wp,
/***********************************************************************
* ANDROID_MsgWaitForMultipleObjectsEx
*/
DWORD ANDROID_MsgWaitForMultipleObjectsEx( DWORD count, const HANDLE *handles,
DWORD timeout, DWORD mask, DWORD flags )
NTSTATUS ANDROID_MsgWaitForMultipleObjectsEx( DWORD count, const HANDLE *handles,
const LARGE_INTEGER *timeout,
DWORD mask, DWORD flags )
{
if (GetCurrentThreadId() == desktop_tid)
{
@ -1210,8 +1211,8 @@ DWORD ANDROID_MsgWaitForMultipleObjectsEx( DWORD count, const HANDLE *handles,
if (current_event) mask = 0;
if (process_events( mask )) return count - 1;
}
return WaitForMultipleObjectsEx( count, handles, flags & MWMO_WAITALL,
timeout, flags & MWMO_ALERTABLE );
return NtWaitForMultipleObjects( count, handles, !(flags & MWMO_WAITALL),
!!(flags & MWMO_ALERTABLE), timeout );
}
/**********************************************************************

View File

@ -339,21 +339,21 @@ static int process_events(macdrv_event_queue queue, macdrv_event_mask mask)
/***********************************************************************
* MsgWaitForMultipleObjectsEx (MACDRV.@)
*/
DWORD macdrv_MsgWaitForMultipleObjectsEx(DWORD count, const HANDLE *handles,
DWORD timeout, DWORD mask, DWORD flags)
NTSTATUS macdrv_MsgWaitForMultipleObjectsEx(DWORD count, const HANDLE *handles,
const LARGE_INTEGER *timeout, DWORD mask, DWORD flags)
{
DWORD ret;
struct macdrv_thread_data *data = macdrv_thread_data();
macdrv_event_mask event_mask = get_event_mask(mask);
TRACE("count %d, handles %p, timeout %u, mask %x, flags %x\n", count,
TRACE("count %d, handles %p, timeout %p, mask %x, flags %x\n", count,
handles, timeout, mask, flags);
if (!data)
{
if (!count && !timeout) return WAIT_TIMEOUT;
return WaitForMultipleObjectsEx(count, handles, flags & MWMO_WAITALL,
timeout, flags & MWMO_ALERTABLE);
if (!count && timeout && !timeout->QuadPart) return WAIT_TIMEOUT;
return NtWaitForMultipleObjects( count, handles, !(flags & MWMO_WAITALL),
!!(flags & MWMO_ALERTABLE), timeout );
}
if (data->current_event && data->current_event->type != QUERY_EVENT &&
@ -363,10 +363,10 @@ DWORD macdrv_MsgWaitForMultipleObjectsEx(DWORD count, const HANDLE *handles,
event_mask = 0; /* don't process nested events */
if (process_events(data->queue, event_mask)) ret = count - 1;
else if (count || timeout)
else if (count || !timeout || timeout->QuadPart)
{
ret = WaitForMultipleObjectsEx(count, handles, flags & MWMO_WAITALL,
timeout, flags & MWMO_ALERTABLE);
ret = NtWaitForMultipleObjects( count, handles, !(flags & MWMO_WAITALL),
!!(flags & MWMO_ALERTABLE), timeout );
if (ret == count - 1) process_events(data->queue, event_mask);
}
else ret = WAIT_TIMEOUT;

View File

@ -173,8 +173,9 @@ extern INT macdrv_ToUnicodeEx(UINT virtKey, UINT scanCode, const BYTE *lpKeyStat
extern INT macdrv_GetKeyNameText(LONG lparam, LPWSTR buffer, INT size) DECLSPEC_HIDDEN;
extern BOOL macdrv_SystemParametersInfo(UINT action, UINT int_param, void *ptr_param,
UINT flags) DECLSPEC_HIDDEN;
extern DWORD macdrv_MsgWaitForMultipleObjectsEx(DWORD count, const HANDLE *handles,
DWORD timeout, DWORD mask, DWORD flags) DECLSPEC_HIDDEN;
extern NTSTATUS macdrv_MsgWaitForMultipleObjectsEx(DWORD count, const HANDLE *handles,
const LARGE_INTEGER *timeout, DWORD mask,
DWORD flags) DECLSPEC_HIDDEN;
extern void macdrv_ThreadDetach(void) DECLSPEC_HIDDEN;

View File

@ -476,26 +476,26 @@ static BOOL process_events( Display *display, Bool (*filter)(Display*, XEvent*,X
/***********************************************************************
* MsgWaitForMultipleObjectsEx (X11DRV.@)
*/
DWORD X11DRV_MsgWaitForMultipleObjectsEx( DWORD count, const HANDLE *handles,
DWORD timeout, DWORD mask, DWORD flags )
NTSTATUS X11DRV_MsgWaitForMultipleObjectsEx( DWORD count, const HANDLE *handles,
const LARGE_INTEGER *timeout, DWORD mask, DWORD flags )
{
struct x11drv_thread_data *data = x11drv_thread_data();
DWORD ret;
NTSTATUS ret;
if (!data)
{
if (!count && !timeout) return WAIT_TIMEOUT;
return WaitForMultipleObjectsEx( count, handles, flags & MWMO_WAITALL,
timeout, flags & MWMO_ALERTABLE );
if (!count && timeout && !timeout->QuadPart) return WAIT_TIMEOUT;
return NtWaitForMultipleObjects( count, handles, !(flags & MWMO_WAITALL),
!!(flags & MWMO_ALERTABLE), timeout );
}
if (data->current_event) mask = 0; /* don't process nested events */
if (process_events( data->display, filter_event, mask )) ret = count - 1;
else if (count || timeout)
else if (count || !timeout || timeout->QuadPart)
{
ret = WaitForMultipleObjectsEx( count, handles, flags & MWMO_WAITALL,
timeout, flags & MWMO_ALERTABLE );
ret = NtWaitForMultipleObjects( count, handles, !(flags & MWMO_WAITALL),
!!(flags & MWMO_ALERTABLE), timeout );
if (ret == count - 1) process_events( data->display, filter_event, mask );
}
else ret = WAIT_TIMEOUT;

View File

@ -686,8 +686,9 @@ extern void retry_grab_clipping_window(void) DECLSPEC_HIDDEN;
extern BOOL clip_fullscreen_window( HWND hwnd, BOOL reset ) DECLSPEC_HIDDEN;
extern void move_resize_window( HWND hwnd, int dir ) DECLSPEC_HIDDEN;
extern void X11DRV_InitKeyboard( Display *display ) DECLSPEC_HIDDEN;
extern DWORD X11DRV_MsgWaitForMultipleObjectsEx( DWORD count, const HANDLE *handles, DWORD timeout,
DWORD mask, DWORD flags ) DECLSPEC_HIDDEN;
extern NTSTATUS X11DRV_MsgWaitForMultipleObjectsEx( DWORD count, const HANDLE *handles,
const LARGE_INTEGER *timeout,
DWORD mask, DWORD flags ) DECLSPEC_HIDDEN;
extern HWND *build_hwnd_list(void) DECLSPEC_HIDDEN;
typedef int (*x11drv_error_callback)( Display *display, XErrorEvent *event, void *arg );

View File

@ -165,7 +165,7 @@ struct gdi_dc_funcs
};
/* increment this when you change the DC function table */
#define WINE_GDI_DRIVER_VERSION 77
#define WINE_GDI_DRIVER_VERSION 78
#define GDI_PRIORITY_NULL_DRV 0 /* null driver */
#define GDI_PRIORITY_FONT_DRV 100 /* any font driver */
@ -299,7 +299,7 @@ struct user_driver_funcs
void (*pDestroyWindow)(HWND);
void (*pFlashWindowEx)(FLASHWINFO*);
void (*pGetDC)(HDC,HWND,HWND,const RECT *,const RECT *,DWORD);
DWORD (*pMsgWaitForMultipleObjectsEx)(DWORD,const HANDLE*,DWORD,DWORD,DWORD);
NTSTATUS (*pMsgWaitForMultipleObjectsEx)(DWORD,const HANDLE*,const LARGE_INTEGER*,DWORD,DWORD);
void (*pReleaseDC)(HWND,HDC);
BOOL (*pScrollDC)(HDC,INT,INT,HRGN);
void (*pSetCapture)(HWND,UINT);