Trent Waddington : server:
Handle existing timer replacement when no window handle specified.
Alexandre Julliard
julliard at wine.codeweavers.com
Thu Aug 30 13:50:30 CDT 2007
Module: wine
Branch: master
Commit: fc635fa827ad7bef0bb163ea6c2521f1ad1da8c9
URL: http://source.winehq.org/git/wine.git/?a=commit;h=fc635fa827ad7bef0bb163ea6c2521f1ad1da8c9
Author: Trent Waddington <trent.waddington at gmail.com>
Date: Thu Aug 30 19:05:50 2007 +1000
server: Handle existing timer replacement when no window handle specified.
---
dlls/user32/tests/msg.c | 34 ++++++++++++++++++++++++++++++++++
server/queue.c | 19 ++++++++++++++-----
2 files changed, 48 insertions(+), 5 deletions(-)
diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c
index e6443e6..188551c 100644
--- a/dlls/user32/tests/msg.c
+++ b/dlls/user32/tests/msg.c
@@ -6780,6 +6780,39 @@ static void test_timers(void)
ok(DestroyWindow(info.hWnd), "failed to destroy window\n");
}
+static int count = 0;
+static VOID CALLBACK callback_count(
+ HWND hwnd,
+ UINT uMsg,
+ UINT_PTR idEvent,
+ DWORD dwTime
+)
+{
+ count++;
+}
+
+static void test_timers_no_wnd(void)
+{
+ UINT_PTR id, id2;
+ MSG msg;
+
+ count = 0;
+ id = SetTimer(NULL, 0, 100, callback_count);
+ ok(id != 0, "did not get id from SetTimer.\n");
+ id2 = SetTimer(NULL, id, 200, callback_count);
+ ok(id2 == id, "did not get same id from SetTimer when replacing (%li expected %li).\n", id2, id);
+ Sleep(150);
+ while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
+ ok(count == 0, "did not get zero count as expected (%i).\n", count);
+ Sleep(150);
+ while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
+ ok(count == 1, "did not get one count as expected (%i).\n", count);
+ KillTimer(NULL, id);
+ Sleep(250);
+ while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
+ ok(count == 1, "killing replaced timer did not work (%i).\n", count);
+}
+
/* Various win events with arbitrary parameters */
static const struct message WmWinEventsSeq[] = {
{ EVENT_SYSTEM_SOUND, winevent_hook|wparam|lparam, OBJID_WINDOW, 0 },
@@ -9617,6 +9650,7 @@ START_TEST(msg)
test_message_conversion();
test_accelerators();
test_timers();
+ test_timers_no_wnd();
test_set_hook();
test_DestroyWindow();
test_DispatchMessage();
diff --git a/server/queue.c b/server/queue.c
index 1e8de22..cdab2a8 100644
--- a/server/queue.c
+++ b/server/queue.c
@@ -1927,13 +1927,22 @@ DECL_HANDLER(set_win_timer)
else
{
queue = get_current_queue();
- /* find a free id for it */
- do
+ /* look for a timer with this id */
+ if (id && (timer = find_timer( queue, NULL, req->msg, id )))
{
- id = queue->next_timer_id;
- if (++queue->next_timer_id >= 0x10000) queue->next_timer_id = 1;
+ /* free and reuse id */
+ free_timer( queue, timer );
+ }
+ else
+ {
+ /* find a free id for it */
+ do
+ {
+ id = queue->next_timer_id;
+ if (++queue->next_timer_id >= 0x10000) queue->next_timer_id = 1;
+ }
+ while (find_timer( queue, 0, req->msg, id ));
}
- while (find_timer( queue, 0, req->msg, id ));
}
if ((timer = set_timer( queue, req->rate )))
More information about the wine-cvs
mailing list