Skip to content

Commit 1456f87

Browse files
authored
Merge pull request #23636 from greglucas/macosx-flush-events
FIX: macosx flush_events should process all events
2 parents 7e1e1e7 + 9921e39 commit 1456f87

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/_macosx.m

+14-3
Original file line numberDiff line numberDiff line change
@@ -391,9 +391,20 @@ static CGFloat _get_device_scale(CGContextRef cr)
391391
static PyObject*
392392
FigureCanvas_flush_events(FigureCanvas* self)
393393
{
394-
// We need to allow the runloop to run very briefly
395-
// to allow the view to be displayed when used in a fast updating animation
396-
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.0]];
394+
// We run the app, matching any events that are waiting in the queue
395+
// to process, breaking out of the loop when no events remain and
396+
// displaying the canvas if needed.
397+
NSEvent *event;
398+
while (true) {
399+
event = [NSApp nextEventMatchingMask: NSEventMaskAny
400+
untilDate: [NSDate distantPast]
401+
inMode: NSDefaultRunLoopMode
402+
dequeue: YES];
403+
if (!event) {
404+
break;
405+
}
406+
[NSApp sendEvent:event];
407+
}
397408
[self->view displayIfNeeded];
398409
Py_RETURN_NONE;
399410
}

0 commit comments

Comments
 (0)