8000 Calculate initial GTK window size using logical DPI · matplotlib/matplotlib@f53c28d · GitHub
[go: up one dir, main page]

Skip to content

Commit f53c28d

Browse files
committed
Calculate initial GTK window size using logical DPI
Otherwise, if the pixel ratio is changed before the window is created, the window will be scaled up an extra time. This occurs on GTK3, but not GTK4, due to some different order of events, but I changed the GTK4 backend to do the same for consistency.
1 parent 0c0fc47 commit f53c28d

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

lib/matplotlib/backends/backend_gtk3.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,7 @@ def __init__(self, canvas, num):
340340

341341
self.vbox.pack_start(self.canvas, True, True, 0)
342342
# calculate size for window
343-
w = int(self.canvas.figure.bbox.width)
344-
h = int(self.canvas.figure.bbox.height)
343+
w, h = self.canvas.get_width_height()
345344

346345
self.toolbar = self._get_toolbar()
347346

lib/matplotlib/backends/backend_gtk4.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,7 @@ def __init__(self, canvas, num):
287287

288288
self.vbox.prepend(self.canvas)
289289
# calculate size for window
290-
w = int(self.canvas.figure.bbox.width)
291-
h = int(self.canvas.figure.bbox.height)
290+
w, h = self.canvas.get_width_height()
292291

293292
self.toolbar = self._get_toolbar()
294293

0 commit comments

Comments
 (0)
0