Commit a97fd9f2 authored by Paul Gofman's avatar Paul Gofman Committed by Alexandre Julliard

win32u: Expose and use ProcessEvents from drivers instead of MsgWaitForMultipleObjectsEx.

parent 13a65b84
...@@ -1449,7 +1449,6 @@ static void update_now( HWND hwnd, UINT rdw_flags ) ...@@ -1449,7 +1449,6 @@ static void update_now( HWND hwnd, UINT rdw_flags )
*/ */
BOOL WINAPI NtUserRedrawWindow( HWND hwnd, const RECT *rect, HRGN hrgn, UINT flags ) BOOL WINAPI NtUserRedrawWindow( HWND hwnd, const RECT *rect, HRGN hrgn, UINT flags )
{ {
LARGE_INTEGER zero = { .QuadPart = 0 };
static const RECT empty; static const RECT empty;
BOOL ret; BOOL ret;
...@@ -1470,7 +1469,7 @@ BOOL WINAPI NtUserRedrawWindow( HWND hwnd, const RECT *rect, HRGN hrgn, UINT fla ...@@ -1470,7 +1469,7 @@ BOOL WINAPI NtUserRedrawWindow( HWND hwnd, const RECT *rect, HRGN hrgn, UINT fla
} }
/* process pending expose events before painting */ /* process pending expose events before painting */
if (flags & RDW_UPDATENOW) user_driver->pMsgWaitForMultipleObjectsEx( 0, NULL, &zero, QS_PAINT, 0 ); if (flags & RDW_UPDATENOW) user_driver->pProcessEvents( QS_PAINT );
if (rect && !hrgn) if (rect && !hrgn)
{ {
......
...@@ -806,13 +806,9 @@ static void nulldrv_GetDC( HDC hdc, HWND hwnd, HWND top_win, const RECT *win_rec ...@@ -806,13 +806,9 @@ static void nulldrv_GetDC( HDC hdc, HWND hwnd, HWND top_win, const RECT *win_rec
{ {
} }
static NTSTATUS nulldrv_MsgWaitForMultipleObjectsEx( DWORD count, const HANDLE *handles, static BOOL nulldrv_ProcessEvents( DWORD mask )
const LARGE_INTEGER *timeout,
DWORD mask, DWORD flags )
{ {
if (!count && timeout && !timeout->QuadPart) return WAIT_TIMEOUT; return FALSE;
return NtWaitForMultipleObjects( count, handles, !(flags & MWMO_WAITALL),
!!(flags & MWMO_ALERTABLE), timeout );
} }
static void nulldrv_ReleaseDC( HWND hwnd, HDC hdc ) static void nulldrv_ReleaseDC( HWND hwnd, HDC hdc )
...@@ -1193,7 +1189,7 @@ static const struct user_driver_funcs lazy_load_driver = ...@@ -1193,7 +1189,7 @@ static const struct user_driver_funcs lazy_load_driver =
nulldrv_DestroyWindow, nulldrv_DestroyWindow,
loaderdrv_FlashWindowEx, loaderdrv_FlashWindowEx,
loaderdrv_GetDC, loaderdrv_GetDC,
nulldrv_MsgWaitForMultipleObjectsEx, nulldrv_ProcessEvents,
nulldrv_ReleaseDC, nulldrv_ReleaseDC,
nulldrv_ScrollDC, nulldrv_ScrollDC,
nulldrv_SetCapture, nulldrv_SetCapture,
...@@ -1268,7 +1264,7 @@ void __wine_set_user_driver( const struct user_driver_funcs *funcs, UINT version ...@@ -1268,7 +1264,7 @@ void __wine_set_user_driver( const struct user_driver_funcs *funcs, UINT version
SET_USER_FUNC(DestroyWindow); SET_USER_FUNC(DestroyWindow);
SET_USER_FUNC(FlashWindowEx); SET_USER_FUNC(FlashWindowEx);
SET_USER_FUNC(GetDC); SET_USER_FUNC(GetDC);
SET_USER_FUNC(MsgWaitForMultipleObjectsEx); SET_USER_FUNC(ProcessEvents);
SET_USER_FUNC(ReleaseDC); SET_USER_FUNC(ReleaseDC);
SET_USER_FUNC(ScrollDC); SET_USER_FUNC(ScrollDC);
SET_USER_FUNC(SetCapture); SET_USER_FUNC(SetCapture);
......
...@@ -750,8 +750,7 @@ BOOL WINAPI NtUserGetCursorInfo( CURSORINFO *info ) ...@@ -750,8 +750,7 @@ BOOL WINAPI NtUserGetCursorInfo( CURSORINFO *info )
static void check_for_events( UINT flags ) static void check_for_events( UINT flags )
{ {
LARGE_INTEGER zero = { .QuadPart = 0 }; if (!user_driver->pProcessEvents( flags ))
if (user_driver->pMsgWaitForMultipleObjectsEx( 0, NULL, &zero, flags, 0 ) == WAIT_TIMEOUT)
flush_window_surfaces( TRUE ); flush_window_surfaces( TRUE );
} }
......
...@@ -2086,9 +2086,8 @@ static inline void check_for_driver_events( UINT msg ) ...@@ -2086,9 +2086,8 @@ static inline void check_for_driver_events( UINT msg )
{ {
if (get_user_thread_info()->message_count > 200) if (get_user_thread_info()->message_count > 200)
{ {
LARGE_INTEGER zero = { .QuadPart = 0 };
flush_window_surfaces( FALSE ); flush_window_surfaces( FALSE );
user_driver->pMsgWaitForMultipleObjectsEx( 0, NULL, &zero, QS_ALLINPUT, 0 ); user_driver->pProcessEvents( QS_ALLINPUT );
} }
else if (msg == WM_TIMER || msg == WM_SYSTIMER) else if (msg == WM_TIMER || msg == WM_SYSTIMER)
{ {
...@@ -2117,13 +2116,20 @@ static DWORD wait_message( DWORD count, const HANDLE *handles, DWORD timeout, DW ...@@ -2117,13 +2116,20 @@ static DWORD wait_message( DWORD count, const HANDLE *handles, DWORD timeout, DW
if (enable_thunk_lock) if (enable_thunk_lock)
lock = KeUserModeCallback( NtUserThunkLock, NULL, 0, &ret_ptr, &ret_len ); lock = KeUserModeCallback( NtUserThunkLock, NULL, 0, &ret_ptr, &ret_len );
ret = user_driver->pMsgWaitForMultipleObjectsEx( count, handles, get_nt_timeout( &time, timeout ), if (user_driver->pProcessEvents( mask )) ret = count ? count - 1 : 0;
mask, flags ); else if (count)
if (HIWORD(ret)) /* is it an error code? */
{ {
RtlSetLastWin32Error( RtlNtStatusToDosError(ret) ); ret = NtWaitForMultipleObjects( count, handles, !(flags & MWMO_WAITALL),
ret = WAIT_FAILED; !!(flags & MWMO_ALERTABLE), get_nt_timeout( &time, timeout ));
if (ret == count - 1) user_driver->pProcessEvents( mask );
else if (HIWORD(ret)) /* is it an error code? */
{
RtlSetLastWin32Error( RtlNtStatusToDosError(ret) );
ret = WAIT_FAILED;
}
} }
else ret = WAIT_TIMEOUT;
if (ret == WAIT_TIMEOUT && !count && !timeout) NtYieldExecution(); if (ret == WAIT_TIMEOUT && !count && !timeout) NtYieldExecution();
if ((mask & QS_INPUT) == QS_INPUT) get_user_thread_info()->message_count = 0; if ((mask & QS_INPUT) == QS_INPUT) get_user_thread_info()->message_count = 0;
......
...@@ -89,9 +89,7 @@ extern SHORT ANDROID_VkKeyScanEx( WCHAR ch, HKL hkl ) DECLSPEC_HIDDEN; ...@@ -89,9 +89,7 @@ extern SHORT ANDROID_VkKeyScanEx( WCHAR ch, HKL hkl ) DECLSPEC_HIDDEN;
extern void ANDROID_SetCursor( HCURSOR handle ) DECLSPEC_HIDDEN; extern void ANDROID_SetCursor( HCURSOR handle ) DECLSPEC_HIDDEN;
extern BOOL ANDROID_CreateWindow( HWND hwnd ) DECLSPEC_HIDDEN; extern BOOL ANDROID_CreateWindow( HWND hwnd ) DECLSPEC_HIDDEN;
extern void ANDROID_DestroyWindow( HWND hwnd ) DECLSPEC_HIDDEN; extern void ANDROID_DestroyWindow( HWND hwnd ) DECLSPEC_HIDDEN;
extern NTSTATUS ANDROID_MsgWaitForMultipleObjectsEx( DWORD count, const HANDLE *handles, extern BOOL ANDROID_ProcessEvents( DWORD mask ) DECLSPEC_HIDDEN;
const LARGE_INTEGER *timeout,
DWORD mask, DWORD flags ) DECLSPEC_HIDDEN;
extern LRESULT ANDROID_DesktopWindowProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp ) DECLSPEC_HIDDEN; extern LRESULT ANDROID_DesktopWindowProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp ) DECLSPEC_HIDDEN;
extern void ANDROID_SetCursor( HCURSOR handle ) DECLSPEC_HIDDEN; extern void ANDROID_SetCursor( HCURSOR handle ) DECLSPEC_HIDDEN;
extern void ANDROID_SetLayeredWindowAttributes( HWND hwnd, COLORREF key, BYTE alpha, extern void ANDROID_SetLayeredWindowAttributes( HWND hwnd, COLORREF key, BYTE alpha,
......
...@@ -352,7 +352,7 @@ static const struct user_driver_funcs android_drv_funcs = ...@@ -352,7 +352,7 @@ static const struct user_driver_funcs android_drv_funcs =
.pCreateWindow = ANDROID_CreateWindow, .pCreateWindow = ANDROID_CreateWindow,
.pDesktopWindowProc = ANDROID_DesktopWindowProc, .pDesktopWindowProc = ANDROID_DesktopWindowProc,
.pDestroyWindow = ANDROID_DestroyWindow, .pDestroyWindow = ANDROID_DestroyWindow,
.pMsgWaitForMultipleObjectsEx = ANDROID_MsgWaitForMultipleObjectsEx, .pProcessEvents = ANDROID_ProcessEvents,
.pSetCapture = ANDROID_SetCapture, .pSetCapture = ANDROID_SetCapture,
.pSetLayeredWindowAttributes = ANDROID_SetLayeredWindowAttributes, .pSetLayeredWindowAttributes = ANDROID_SetLayeredWindowAttributes,
.pSetParent = ANDROID_SetParent, .pSetParent = ANDROID_SetParent,
......
...@@ -1200,20 +1200,17 @@ LRESULT ANDROID_DesktopWindowProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp ) ...@@ -1200,20 +1200,17 @@ LRESULT ANDROID_DesktopWindowProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
/*********************************************************************** /***********************************************************************
* ANDROID_MsgWaitForMultipleObjectsEx * ANDROID_ProcessEvents
*/ */
NTSTATUS ANDROID_MsgWaitForMultipleObjectsEx( DWORD count, const HANDLE *handles, BOOL ANDROID_ProcessEvents( DWORD mask )
const LARGE_INTEGER *timeout,
DWORD mask, DWORD flags )
{ {
if (GetCurrentThreadId() == desktop_tid) if (GetCurrentThreadId() == desktop_tid)
{ {
/* don't process nested events */ /* don't process nested events */
if (current_event) mask = 0; if (current_event) mask = 0;
if (process_events( mask )) return count - 1; return process_events( mask );
} }
return NtWaitForMultipleObjects( count, handles, !(flags & MWMO_WAITALL), return FALSE;
!!(flags & MWMO_ALERTABLE), timeout );
} }
/********************************************************************** /**********************************************************************
......
...@@ -510,24 +510,16 @@ static int process_events(macdrv_event_queue queue, macdrv_event_mask mask) ...@@ -510,24 +510,16 @@ static int process_events(macdrv_event_queue queue, macdrv_event_mask mask)
/*********************************************************************** /***********************************************************************
* MsgWaitForMultipleObjectsEx (MACDRV.@) * ProcessEvents (MACDRV.@)
*/ */
NTSTATUS macdrv_MsgWaitForMultipleObjectsEx(DWORD count, const HANDLE *handles, NTSTATUS macdrv_ProcessEvents(DWORD mask)
const LARGE_INTEGER *timeout, DWORD mask, DWORD flags)
{ {
DWORD ret;
struct macdrv_thread_data *data = macdrv_thread_data(); struct macdrv_thread_data *data = macdrv_thread_data();
macdrv_event_mask event_mask = get_event_mask(mask); macdrv_event_mask event_mask = get_event_mask(mask);
TRACE("count %d, handles %p, timeout %p, mask %x, flags %x\n", (unsigned int)count, TRACE("mask %x\n", (unsigned int)mask);
handles, timeout, (unsigned int)mask, (unsigned int)flags);
if (!data) if (!data) return FALSE;
{
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 && if (data->current_event && data->current_event->type != QUERY_EVENT &&
data->current_event->type != QUERY_EVENT_NO_PREEMPT_WAIT && data->current_event->type != QUERY_EVENT_NO_PREEMPT_WAIT &&
...@@ -535,14 +527,5 @@ NTSTATUS macdrv_MsgWaitForMultipleObjectsEx(DWORD count, const HANDLE *handles, ...@@ -535,14 +527,5 @@ NTSTATUS macdrv_MsgWaitForMultipleObjectsEx(DWORD count, const HANDLE *handles,
data->current_event->type != WINDOW_DRAG_BEGIN) data->current_event->type != WINDOW_DRAG_BEGIN)
event_mask = 0; /* don't process nested events */ event_mask = 0; /* don't process nested events */
if (process_events(data->queue, event_mask)) ret = count - 1; return process_events(data->queue, event_mask);
else if (count || !timeout || timeout->QuadPart)
{
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;
return ret;
} }
...@@ -282,7 +282,7 @@ static const struct user_driver_funcs macdrv_funcs = ...@@ -282,7 +282,7 @@ static const struct user_driver_funcs macdrv_funcs =
.pGetKeyboardLayoutList = macdrv_GetKeyboardLayoutList, .pGetKeyboardLayoutList = macdrv_GetKeyboardLayoutList,
.pGetKeyNameText = macdrv_GetKeyNameText, .pGetKeyNameText = macdrv_GetKeyNameText,
.pMapVirtualKeyEx = macdrv_MapVirtualKeyEx, .pMapVirtualKeyEx = macdrv_MapVirtualKeyEx,
.pMsgWaitForMultipleObjectsEx = macdrv_MsgWaitForMultipleObjectsEx, .pProcessEvents = macdrv_ProcessEvents,
.pRegisterHotKey = macdrv_RegisterHotKey, .pRegisterHotKey = macdrv_RegisterHotKey,
.pSetCapture = macdrv_SetCapture, .pSetCapture = macdrv_SetCapture,
.pSetCursor = macdrv_SetCursor, .pSetCursor = macdrv_SetCursor,
......
...@@ -169,9 +169,7 @@ extern UINT macdrv_GetKeyboardLayoutList(INT size, HKL *list) DECLSPEC_HIDDEN; ...@@ -169,9 +169,7 @@ extern UINT macdrv_GetKeyboardLayoutList(INT size, HKL *list) DECLSPEC_HIDDEN;
extern INT macdrv_GetKeyNameText(LONG lparam, LPWSTR buffer, INT size) DECLSPEC_HIDDEN; extern INT macdrv_GetKeyNameText(LONG lparam, LPWSTR buffer, INT size) DECLSPEC_HIDDEN;
extern BOOL macdrv_SystemParametersInfo(UINT action, UINT int_param, void *ptr_param, extern BOOL macdrv_SystemParametersInfo(UINT action, UINT int_param, void *ptr_param,
UINT flags) DECLSPEC_HIDDEN; UINT flags) DECLSPEC_HIDDEN;
extern NTSTATUS macdrv_MsgWaitForMultipleObjectsEx(DWORD count, const HANDLE *handles, extern BOOL macdrv_ProcessEvents(DWORD mask) DECLSPEC_HIDDEN;
const LARGE_INTEGER *timeout, DWORD mask,
DWORD flags) DECLSPEC_HIDDEN;
extern void macdrv_ThreadDetach(void) DECLSPEC_HIDDEN; extern void macdrv_ThreadDetach(void) DECLSPEC_HIDDEN;
......
...@@ -472,33 +472,16 @@ static BOOL process_events( Display *display, Bool (*filter)(Display*, XEvent*,X ...@@ -472,33 +472,16 @@ static BOOL process_events( Display *display, Bool (*filter)(Display*, XEvent*,X
/*********************************************************************** /***********************************************************************
* MsgWaitForMultipleObjectsEx (X11DRV.@) * ProcessEvents (X11DRV.@)
*/ */
NTSTATUS X11DRV_MsgWaitForMultipleObjectsEx( DWORD count, const HANDLE *handles, BOOL X11DRV_ProcessEvents( DWORD mask )
const LARGE_INTEGER *timeout, DWORD mask, DWORD flags )
{ {
struct x11drv_thread_data *data = x11drv_thread_data(); struct x11drv_thread_data *data = x11drv_thread_data();
NTSTATUS ret;
if (!data)
{
if (!count && timeout && !timeout->QuadPart) return WAIT_TIMEOUT;
return NtWaitForMultipleObjects( count, handles, !(flags & MWMO_WAITALL),
!!(flags & MWMO_ALERTABLE), timeout );
}
if (!data) return FALSE;
if (data->current_event) mask = 0; /* don't process nested events */ if (data->current_event) mask = 0; /* don't process nested events */
if (process_events( data->display, filter_event, mask )) ret = count - 1; return process_events( data->display, filter_event, mask );
else if (count || !timeout || timeout->QuadPart)
{
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;
return ret;
} }
/*********************************************************************** /***********************************************************************
......
...@@ -413,7 +413,7 @@ static const struct user_driver_funcs x11drv_funcs = ...@@ -413,7 +413,7 @@ static const struct user_driver_funcs x11drv_funcs =
.pDestroyWindow = X11DRV_DestroyWindow, .pDestroyWindow = X11DRV_DestroyWindow,
.pFlashWindowEx = X11DRV_FlashWindowEx, .pFlashWindowEx = X11DRV_FlashWindowEx,
.pGetDC = X11DRV_GetDC, .pGetDC = X11DRV_GetDC,
.pMsgWaitForMultipleObjectsEx = X11DRV_MsgWaitForMultipleObjectsEx, .pProcessEvents = X11DRV_ProcessEvents,
.pReleaseDC = X11DRV_ReleaseDC, .pReleaseDC = X11DRV_ReleaseDC,
.pScrollDC = X11DRV_ScrollDC, .pScrollDC = X11DRV_ScrollDC,
.pSetCapture = X11DRV_SetCapture, .pSetCapture = X11DRV_SetCapture,
......
...@@ -691,9 +691,7 @@ extern void retry_grab_clipping_window(void) DECLSPEC_HIDDEN; ...@@ -691,9 +691,7 @@ extern void retry_grab_clipping_window(void) DECLSPEC_HIDDEN;
extern BOOL clip_fullscreen_window( HWND hwnd, BOOL reset ) 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 move_resize_window( HWND hwnd, int dir ) DECLSPEC_HIDDEN;
extern void X11DRV_InitKeyboard( Display *display ) DECLSPEC_HIDDEN; extern void X11DRV_InitKeyboard( Display *display ) DECLSPEC_HIDDEN;
extern NTSTATUS X11DRV_MsgWaitForMultipleObjectsEx( DWORD count, const HANDLE *handles, extern BOOL X11DRV_ProcessEvents( DWORD mask ) DECLSPEC_HIDDEN;
const LARGE_INTEGER *timeout,
DWORD mask, DWORD flags ) DECLSPEC_HIDDEN;
extern HWND *build_hwnd_list(void) DECLSPEC_HIDDEN; extern HWND *build_hwnd_list(void) DECLSPEC_HIDDEN;
typedef int (*x11drv_error_callback)( Display *display, XErrorEvent *event, void *arg ); typedef int (*x11drv_error_callback)( Display *display, XErrorEvent *event, void *arg );
......
...@@ -308,7 +308,7 @@ struct user_driver_funcs ...@@ -308,7 +308,7 @@ struct user_driver_funcs
void (*pDestroyWindow)(HWND); void (*pDestroyWindow)(HWND);
void (*pFlashWindowEx)(FLASHWINFO*); void (*pFlashWindowEx)(FLASHWINFO*);
void (*pGetDC)(HDC,HWND,HWND,const RECT *,const RECT *,DWORD); void (*pGetDC)(HDC,HWND,HWND,const RECT *,const RECT *,DWORD);
NTSTATUS (*pMsgWaitForMultipleObjectsEx)(DWORD,const HANDLE*,const LARGE_INTEGER*,DWORD,DWORD); BOOL (*pProcessEvents)(DWORD);
void (*pReleaseDC)(HWND,HDC); void (*pReleaseDC)(HWND,HDC);
BOOL (*pScrollDC)(HDC,INT,INT,HRGN); BOOL (*pScrollDC)(HDC,INT,INT,HRGN);
void (*pSetCapture)(HWND,UINT); void (*pSetCapture)(HWND,UINT);
......
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