Skip to content

FIX: Update macosx animation handling #22175

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion lib/matplotlib/animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1199,9 +1199,16 @@ def _setup_blit(self):
# axes
self._blit_cache = dict()
self._drawn_artists = []
# _post_draw needs to be called first to initialize the renderer
self._post_draw(None, self._blit)
# Then we need to clear the Frame for the initial draw
# This is typically handled in _on_resize because QT and Tk
# emit a resize event on launch, but the macosx backend does not,
# thus we force it here for everyone for consistency
self._init_draw()
# Connect to future resize events
self._resize_id = self._fig.canvas.mpl_connect('resize_event',
self._on_resize)
self._post_draw(None, self._blit)

def _on_resize(self, event):
# On resize, we need to disable the resize event handling so we don't
Expand Down
2 changes: 2 additions & 0 deletions src/_macosx.m
Original file line number Diff line number Diff line change
Expand Up @@ -1329,6 +1329,8 @@ - (void)updateDevicePixelRatio:(double)scale
goto exit;
}
if (PyObject_IsTrue(change)) {
// Notify that there was a resize_event that took place
gil_call_method(canvas, "resize_event");
[self setNeedsDisplay: YES];
}

Expand Down