Skip to content

Commit d1294c0

Browse files
committed
Qt: Fix HiDPI handling on X11/Windows
With X11, there is only ever a single scale, regardless of monitors as in Wayland, so it's always the highest scale (i.e., it's 2 if you have 1.5&1-scaled monitors). Thus we get no change events and don't update the internal scale. On Wayland though, as noted in the other issue from Qt devs, you only get the fractional scale after the first expose, so there's always at least one event there. In the older/pre-#30345 code path, in `showEvent`, we'd call `_update_screen` to set callbacks for its changes, and that _also_ called `_update_pixel_ratio`. In the new code, we don't have that initial call, and because Wayland always has at least one event at startup, it all seemed to work. So just add the `_update_pixel_ratio` call in the new code path as well. On X11, this will be the highest integer scale needed and never changes. On Wayland, this will also be the rounded-up integer scale, but if using fractional scaling, will change with a subsequent event to the correct one. This does cause a few extra changes on startup, but should be more consistent across platforms.
1 parent a5e1f60 commit d1294c0

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

lib/matplotlib/backends/backend_qt.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ def showEvent(self, event):
273273
window = self.window().windowHandle()
274274
current_version = tuple(int(x) for x in QtCore.qVersion().split('.', 2)[:2])
275275
if current_version >= (6, 6):
276+
self._update_pixel_ratio()
276277
window.installEventFilter(self)
277278
else:
278279
window.screenChanged.connect(self._update_screen)

0 commit comments

Comments
 (0)