Skip to content

Fix: Prevent Cursor blitting from erasing overlapping axes (#25670)#31368

Merged
QuLogic merged 6 commits intomatplotlib:mainfrom
MohitPal2005:fix-blitting-25670
Mar 30, 2026
Merged

Fix: Prevent Cursor blitting from erasing overlapping axes (#25670)#31368
QuLogic merged 6 commits intomatplotlib:mainfrom
MohitPal2005:fix-blitting-25670

Conversation

@MohitPal2005
Copy link
Copy Markdown
Contributor

Fixes #25670.

Bug: When Cursor is used with useblit=True, its background restore operation blindly overwrites any overlapping widgets (like CheckButtons residing in a different axes on the same figure), causing them to flicker or disappear.

Fix: Updated Cursor.onmove to explicitly detect if any other axes overlap with the cursor's main axes bounding box. If an overlap is detected, the overlapping axes are explicitly redrawn before blitting to the canvas, preserving their state. This serves as a localized fix for widget interaction prior to a larger architectural overlay manager.

@github-actions
Copy link
Copy Markdown

Thank you for opening your first PR into Matplotlib!

If you have not heard from us in a week or so, please leave a new comment below and that should bring it to our attention. Most of our reviewers are volunteers and sometimes things fall through the cracks. We also ask that you please finish addressing any review comments on this PR and wait for it to be merged (or closed) before opening a new one, as it can be a valuable learning experience to go through the review process.

You can also join us on gitter for real-time discussion.

For details on testing, writing docs, and our review process, please see the developer guide.
Please let us know if (and how) you use AI, it will help us give you better feedback on your PR.

We strive to be a welcoming and open project. Please follow our Code of Conduct.

@MohitPal2005
Copy link
Copy Markdown
Contributor Author

Hi team, I pushed the fixes for the ruff styling checks.

I noticed the docs-python3 CircleCI check is failing on the environment setup ([Errno 2] No such file or directory: 'requirements/dev/build-requirements.txt'). Since my changes are strictly isolated to lib/matplotlib/widgets.py, I suspect this might be an unrelated upstream CI issue.

Please let me know if there is anything specific you need me to adjust on my end!

@melissawm melissawm moved this to Needs review in First Time Contributors Mar 25, 2026
@melissawm
Copy link
Copy Markdown
Member

CircleCI is showing a degraded status banner right now so it could be a transient issue. Maybe we can re-trigger the build later.

@MohitPal2005
Copy link
Copy Markdown
Contributor Author

Thanks @melissawm!

Just as a heads up, the Main Pytest Windows_py313 check also failed. Looking at the logs, it appears to be due to a subprocess.TimeoutExpired in test_interactive_thread_safety and test_lazy_auto_backend_selection. Since both tests are marked as flaky and involve interactive backends, this seems like an unrelated CI timeout rather than anything caused by my changes in widgets.py.

Please let me know if you would like me to investigate further or make any adjustments. Happy to help!

@melissawm
Copy link
Copy Markdown
Member

Looking at this more carefully, it looks like you may need to rebase to main, since the circleci action should not be looking for a requirements file anymore:

python -m pip install --user \

@MohitPal2005
Copy link
Copy Markdown
Contributor Author

Hi @melissawm, the rebase was successful!

However, it looks like the Main Pytest Windows and Python 3.13t checks are failing catastrophically now (hitting the 100-failure abort limit instantly). Since my changes are strictly scoped to the Cursor blitting logic in widgets.py, I assume this is a larger upstream environment issue with those specific CI runners. Let me know if you need me to do anything else!

Copy link
Copy Markdown
Member

@timhoffm timhoffm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CI failures are fixed by #31401. You'd need to rebase again.

But I'm not convinced this is a sustainable solution. Artists forcing drawing other artists to redraw is a recipe for messing up the draw architecture. I'm of the opinion that the case of #25670 should be regarded as not supported for now and #30515 or #30953 are the proper ways to fix this.

@MohitPal2005
Copy link
Copy Markdown
Contributor Author

Hi @timhoffm, thanks for the detailed feedback!

That makes sense — I understand the concern about forcing redraws breaking the rendering architecture.

I’ll update the PR to instead treat this case as unsupported for now, and align with the approach discussed in #30515 and #30953.

Thanks again for the guidance!

@MohitPal2005 MohitPal2005 requested a review from timhoffm March 29, 2026 22:51
@MohitPal2005
Copy link
Copy Markdown
Contributor Author

Hi @timhoffm, I’ve pushed updates addressing the feedback.

The forced redraw logic has been removed. Now the Cursor checks for overlapping axes during initialization, issues a warning, and falls back to useblit=False.

Please let me know if this approach looks good!

Copy link
Copy Markdown
Member

@timhoffm timhoffm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning on __init__ seems a good solution.

Please remove the unnecessary changes as suggested in my comments.

@timhoffm timhoffm dismissed their stale review March 30, 2026 07:59

Comments are handled.

@MohitPal2005
Copy link
Copy Markdown
Contributor Author

Hi @timhoffm, it looks like the remaining AppVeyor failure is due to a timeout rather than a code issue.

Could you please re-trigger it when you have a moment? Thanks!

@QuLogic QuLogic added this to the v3.11.0 milestone Mar 30, 2026
@QuLogic QuLogic merged commit 7c7e251 into matplotlib:main Mar 30, 2026
39 of 41 checks passed
@github-project-automation github-project-automation bot moved this from Needs review to Merged in First Time Contributors Mar 30, 2026
@QuLogic
Copy link
Copy Markdown
Member

QuLogic commented Mar 30, 2026

Thanks @MohitPal2005! Congratulations on your first PR to Matplotlib 🎉 We hope to hear from you again.

@MohitPal2005
Copy link
Copy Markdown
Contributor Author

Thank you so much @QuLogic and @timhoffm for the reviews, patience, and guidance! I learned a ton navigating this and really look forward to contributing more soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Development

Successfully merging this pull request may close these issues.

[Bug]: Cursor blitting produces CheckButton issue (backend-agnostic)

4 participants