From 57b7a9937deb3f01960fc426f6cedf2b79fd7885 Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Fri, 29 Apr 2016 12:34:53 +0200 Subject: [PATCH] user32: Implement SetCoalescableTimer and add basic tests. Signed-off-by: Sebastian Lackner Signed-off-by: Alexandre Julliard --- dlls/user32/message.c | 13 +++++++++++-- dlls/user32/tests/msg.c | 16 ++++++++++++++++ dlls/user32/user32.spec | 1 + include/winuser.h | 7 +++++++ 4 files changed, 35 insertions(+), 2 deletions(-) diff --git a/dlls/user32/message.c b/dlls/user32/message.c index fb4786b91ec..bc6b6618bee 100644 --- a/dlls/user32/message.c +++ b/dlls/user32/message.c @@ -4443,9 +4443,9 @@ BOOL WINAPI MessageBeep( UINT i ) /*********************************************************************** - * SetTimer (USER32.@) + * SetCoalescableTimer (USER32.@) */ -UINT_PTR WINAPI SetTimer( HWND hwnd, UINT_PTR id, UINT timeout, TIMERPROC proc ) +UINT_PTR WINAPI SetCoalescableTimer( HWND hwnd, UINT_PTR id, UINT timeout, TIMERPROC proc, ULONG tolerance ) { UINT_PTR ret; WNDPROC winproc = 0; @@ -4475,6 +4475,15 @@ UINT_PTR WINAPI SetTimer( HWND hwnd, UINT_PTR id, UINT timeout, TIMERPROC proc ) } +/****************************************************************** + * SetTimer (USER32.@) + */ +UINT_PTR WINAPI SetTimer( HWND hwnd, UINT_PTR id, UINT timeout, TIMERPROC proc ) +{ + return SetCoalescableTimer( hwnd, id, timeout, proc, TIMERV_DEFAULT_COALESCING ); +} + + /*********************************************************************** * SetSystemTimer (USER32.@) */ diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c index 8ab6e15064e..e39f8a1e5bb 100644 --- a/dlls/user32/tests/msg.c +++ b/dlls/user32/tests/msg.c @@ -1743,6 +1743,7 @@ static HMONITOR (WINAPI *pMonitorFromPoint)(POINT,DWORD); static BOOL (WINAPI *pUpdateLayeredWindow)(HWND,HDC,POINT*,SIZE*,HDC,POINT*,COLORREF,BLENDFUNCTION*,DWORD); static UINT_PTR (WINAPI *pSetSystemTimer)(HWND, UINT_PTR, UINT, TIMERPROC); static UINT_PTR (WINAPI *pKillSystemTimer)(HWND, UINT_PTR); +static UINT_PTR (WINAPI *pSetCoalescableTimer)(HWND, UINT_PTR, UINT, TIMERPROC, ULONG); /* kernel32 functions */ static BOOL (WINAPI *pGetCPInfoExA)(UINT, DWORD, LPCPINFOEXA); @@ -1769,6 +1770,7 @@ static void init_procs(void) GET_PROC(user32, UpdateLayeredWindow) GET_PROC(user32, SetSystemTimer) GET_PROC(user32, KillSystemTimer) + GET_PROC(user32, SetCoalescableTimer) GET_PROC(kernel32, GetCPInfoExA) @@ -8995,6 +8997,20 @@ static void test_timers_no_wnd(void) KillTimer(NULL, id); /* Note: SetSystemTimer doesn't support a NULL window, see test_timers */ + if (pSetCoalescableTimer) + { + count = 0; + id = pSetCoalescableTimer(NULL, 0, 0, callback_count, 0); + ok(id != 0, "SetCoalescableTimer failed with %u.\n", GetLastError()); + start = GetTickCount(); + while (GetTickCount()-start < 100 && GetMessageA(&msg, NULL, 0, 0)) + DispatchMessageA(&msg); + ok(count > 1, "expected count > 1, got %d.\n", count); + KillTimer(NULL, id); + } + else + win_skip("SetCoalescableTimer not available.\n"); + /* Check what happens when we're running out of timers */ for (i=0; i