Skip to content

Fix GTK cairo backends #28451

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 2 commits into from
Jul 3, 2024
Merged

Fix GTK cairo backends #28451

merged 2 commits into from
Jul 3, 2024

Conversation

QuLogic
Copy link
Member

@QuLogic QuLogic commented Jun 25, 2024

PR summary

For GTK4Cairo, HiDPI displays were broken because we were scaling unnecessarily, as GTK4 takes care of setting up the Cairo context for us with the right scale.

For GTK3Cairo, all displays were broken, as we inferred the size from the backing surface (since #22004), which is the size of the window. Then we re-orient the origin using that height, causing everything to be placed incorrectly.

PR checklist

QuLogic added 2 commits June 25, 2024 00:12
With GTK4, the Cairo context we get is always in logical pixels, and is
automatically scaled to the right size, without any worry about
blurriness. So in that case, we can ignore all scale factor changes, and
assume it's always 1.

The remaining effect of tracking scale factor changes is to trigger a
re-draw, but GTK will send a resize event to go along with it, which
will do that for us.

Fixes matplotlib#25847
Replaces matplotlib#25861
With GTK3, the Cairo surface we get is for the whole window, which means
the automatic size inference from matplotlib#22004 gets the wrong size. For the
GtkDrawingArea, the Cairo context is aligned and clipped to the widget,
so nothing goes out-of-bounds. However, since the Cairo renderer flips
the origin using the height in the calculation (which is, for the
window, bigger than the drawing widget), everything is drawn lower than
it should.
@ksunden ksunden merged commit 0ad8ee1 into matplotlib:main Jul 3, 2024
51 checks passed
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Jul 3, 2024
@ksunden ksunden mentioned this pull request Jul 3, 2024
2 tasks
@QuLogic QuLogic deleted the gtk-cairo-hidpi branch July 3, 2024 20:11
QuLogic added a commit that referenced this pull request Jul 4, 2024
…451-on-v3.9.x

Backport PR #28451 on branch v3.9.x (Fix GTK cairo backends)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants