@@ -52,6 +52,7 @@ def _mpl_to_gtk_cursor(mpl_cursor):
52
52
class FigureCanvasGTK4 (Gtk .DrawingArea , FigureCanvasBase ):
53
53
required_interactive_framework = "gtk4"
54
54
_timer_cls = TimerGTK4
55
+ _context_is_scaled = False
55
56
56
57
def __init__ (self , figure = None ):
57
58
FigureCanvasBase .__init__ (self , figure )
@@ -205,8 +206,15 @@ def _post_draw(self, widget, ctx):
205
206
if self ._rubberband_rect is None :
206
207
return
207
208
208
- x0 , y0 , w , h = (dim / self .device_pixel_ratio
209
- for dim in self ._rubberband_rect )
209
+ lw = 1
210
+ dash = 3
211
+ if not self ._context_is_scaled :
212
+ x0 , y0 , w , h = (dim / self .device_pixel_ratio
213
+ for dim in self ._rubberband_rect )
214
+ else :
215
+ x0 , y0 , w , h = self ._rubberband_rect
216
+ lw *= self .device_pixel_ratio
217
+ dash *= self .device_pixel_ratio
210
218
x1 = x0 + w
211
219
y1 = y0 + h
212
220
@@ -222,12 +230,12 @@ def _post_draw(self, widget, ctx):
222
230
ctx .line_to (x1 , y1 )
223
231
224
232
ctx .set_antialias (1 )
225
- ctx .set_line_width (1 )
226
- ctx .set_dash ((3 , 3 ), 0 )
233
+ ctx .set_line_width (lw )
234
+ ctx .set_dash ((dash , dash ), 0 )
227
235
ctx .set_source_rgb (0 , 0 , 0 )
228
236
ctx .stroke_preserve ()
229
237
230
- ctx .set_dash ((3 , 3 ), 3 )
238
+ ctx .set_dash ((dash , dash ), dash )
231
239
ctx .set_source_rgb (1 , 1 , 1 )
232
240
ctx .stroke ()
233
241
0 commit comments