From 617dc2ce12eb6183b4ae3d3fe73572e43629c825 Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Thu, 23 Jun 2022 19:12:35 +0200 Subject: Fix for issue #450: Fl_Counter slips into infinite loop. This issue revealed that the macOS and Wayland platform processed events slightly differently from other platforms. Under X11 and Windows, Fl::wait() processes one event if one is present, and also all other events present in the event queue immediately after the processing of that event. Under macOS and Wayland, Fl::wait() processes one event if one is present and returns. This commits makes the macOS and Wayland platforms behave as other platforms. --- src/Fl_cocoa.mm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/Fl_cocoa.mm') diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm index 1fe7f68cc..889b5c37b 100644 --- a/src/Fl_cocoa.mm +++ b/src/Fl_cocoa.mm @@ -768,12 +768,14 @@ static int do_queued_events( double time = 0.0 ) time = Fl_Timeout::time_to_wait(time); fl_unlock_function(); - NSEvent *event = [NSApp nextEventMatchingMask:NSAnyEventMask + NSEvent *event; + while ( (event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate dateWithTimeIntervalSinceNow:time] - inMode:NSDefaultRunLoopMode dequeue:YES]; - if (event != nil) { + inMode:NSDefaultRunLoopMode + dequeue:YES]) != nil ) { got_events = 1; [FLApplication sendEvent:event]; // will then call [NSApplication sendevent:] + time = 0; } fl_lock_function(); -- cgit v1.2.3