8000 FIX: macosx flush_events should process all events · matplotlib/matplotlib@5feace7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5feace7

Browse files
committed
FIX: macosx flush_events should process all events
1 parent 276436a commit 5feace7

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/_macosx.m

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

0 commit comments

Comments
 (0)
0