-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix resize bugs in GTK #16972
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
Fix resize bugs in GTK #16972
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This is essentially a revert of the `Text.get_window_extent` change to its dpi handling, but applies in _all_ cases. Depending on backend, we want to avoid this extraneous dpi change, because it can cause recursive event signals. For example, with GTK3, a resize will trigger its event loop, which eventually causes a re-draw. The re-draw would get to `Text.get_window_extent`, change the dpi (to the same value), and call `Figure.set_size_inches`, which would resize the window again. Depending on how much of the GTK event loop was processed, this may or may not trigger another draw, recursing again and again. Fixes matplotlib#16934.
Previously, it was the window that was resized to the intended size, thus making the canvas smaller by the toolbar height. Fixes matplotlib#10083 for GTK3. Fixes matplotlib#10566 for GTK3.
tacaswell
approved these changes
Mar 31, 2020
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change makes sense and tested that this fixes the problem locally.
The figure is no longer set stale because `resize` is no longer called. There's no reason the figure should be stale until it's ready to be drawn, but we don't really need a whole main loop for this test.
I'm not 100% on that last test fix as I'm not sure what it's trying to trigger. |
6 tasks
This also fixes some kind of refresh loop in nbagg. |
anntzer
approved these changes
Apr 4, 2020
lgtm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Summary
This fixes #16934 by essentially reverting the
Text.get_window_extent
change, but in a more general way. Avoiding redundant event signals for changing DPI is somewhat safer for all backends as we can't really control whether a backend will trigger another draw on resize or not (ok, we could block their signals, but this is simpler). By doing it in theFigure.set_dpi
method, it covers all cases that might come up in the future, and not just theText
one.The second commit also fixes #10083 and #10566 for GTK.
PR Checklist