diff options
author | David Robillard <d@drobilla.net> | 2025-01-23 20:23:39 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2025-01-31 17:07:56 -0500 |
commit | 96bcda9180b780eadcbae62eb224503697f7d465 (patch) | |
tree | fc5b1ad577d2fa0512468049824c9e7084b0057a /src/win.c | |
parent | 306c5c66344c2a05ab7c5e0d845b9e36a633aa5b (diff) | |
download | pugl-96bcda9180b780eadcbae62eb224503697f7d465.tar.gz pugl-96bcda9180b780eadcbae62eb224503697f7d465.tar.bz2 pugl-96bcda9180b780eadcbae62eb224503697f7d465.zip |
Windows: Simplify message polling
The internal puglPollWinEvents() abstraction was doing more harm than good.
Diffstat (limited to 'src/win.c')
-rw-r--r-- | src/win.c | 27 |
1 files changed, 6 insertions, 21 deletions
@@ -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); } } |