From ab21ada7abb8f276a14dbb63e32ce2774456bb1b Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 8 Mar 2020 15:21:39 +0100 Subject: Mac: Prevent indefinite blocking of puglDispatchEvents --- pugl/detail/mac.m | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pugl/detail/mac.m b/pugl/detail/mac.m index f26cb9e..da1ab35 100644 --- a/pugl/detail/mac.m +++ b/pugl/detail/mac.m @@ -927,11 +927,20 @@ puglWaitForEvent(PuglView* view) PUGL_API PuglStatus puglDispatchEvents(PuglWorld* world) { + const NSTimeInterval startTime = [[NSProcessInfo processInfo] systemUptime]; + for (NSEvent* ev = NULL; (ev = [world->impl->app nextEventMatchingMask:NSAnyEventMask untilDate:nil inMode:NSDefaultRunLoopMode dequeue:YES]);) { + + if ([ev timestamp] > startTime) { + // Event is later, put it back for the next iteration and return + [world->impl->app postEvent:ev atStart:true]; + break; + } + [world->impl->app sendEvent: ev]; } -- cgit v1.2.1