From 96bcda9180b780eadcbae62eb224503697f7d465 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 23 Jan 2025 20:23:39 -0500 Subject: Windows: Simplify message polling The internal puglPollWinEvents() abstraction was doing more harm than good. --- src/win.c | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/src/win.c b/src/win.c index 77d6800..2cefd8b 100644 --- a/src/win.c +++ b/src/win.c @@ -270,20 +270,6 @@ puglInitViewInternals(PuglWorld* PUGL_UNUSED(world)) return (PuglInternals*)calloc(1, sizeof(PuglInternals)); } -static PuglStatus -puglPollWinEvents(PuglWorld* world, const double timeout) -{ - (void)world; - - if (timeout < 0) { - WaitMessage(); - } else { - MsgWaitForMultipleObjects( - 0, NULL, FALSE, (DWORD)(timeout * 1e3), QS_ALLEVENTS); - } - return PUGL_SUCCESS; -} - PuglStatus puglRealize(PuglView* view) { @@ -1144,19 +1130,18 @@ puglUpdate(PuglWorld* world, double timeout) PuglStatus st = PUGL_SUCCESS; if (timeout < 0.0) { - st = puglPollWinEvents(world, timeout); - st = st ? st : puglDispatchWinEvents(world); + WaitMessage(); + st = puglDispatchWinEvents(world); } else if (timeout < minWaitSeconds) { st = puglDispatchWinEvents(world); } else { const double endTime = startTime + timeout - minWaitSeconds; double t = startTime; while (!st && t < endTime) { - if ((st = puglPollWinEvents(world, endTime - t)) || - (st = puglDispatchWinEvents(world))) { - break; - } - t = puglGetTime(world); + const DWORD timeoutMs = (DWORD)((endTime - t) * 1e3); + MsgWaitForMultipleObjects(0, NULL, FALSE, timeoutMs, QS_ALLEVENTS); + st = puglDispatchWinEvents(world); + t = puglGetTime(world); } } -- cgit v1.2.1