@@ -13,15 +13,19 @@ def on_draw_event(self, widget, ctx):
1313
1414 with (self .toolbar ._wait_cursor_for_draw_cm () if self .toolbar
1515 else nullcontext ()):
16- self ._renderer .set_context (ctx )
17- scale = self .device_pixel_ratio
18- # Scale physical drawing to logical size.
19- ctx .scale (1 / scale , 1 / scale )
2016 allocation = self .get_allocation ()
17+ # Render the background before scaling, as the allocated size here is in
18+ # logical pixels.
2119 Gtk .render_background (
2220 self .get_style_context (), ctx ,
23- allocation .x , allocation .y ,
24- allocation .width , allocation .height )
21+ 0 , 0 , allocation .width , allocation .height )
22+ scale = self .device_pixel_ratio
23+ # Scale physical drawing to logical size.
24+ ctx .scale (1 / scale , 1 / scale )
25+ self ._renderer .set_context (ctx )
26+ # Set renderer to physical size so it renders in full resolution.
27+ self ._renderer .width = allocation .width * scale
28+ self ._renderer .height = allocation .height * scale
2529 self ._renderer .dpi = self .figure .dpi
2630 self .figure .draw (self ._renderer )
2731
0 commit comments