diff --git a/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.cxx b/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.cxx index 61d44f6fd..c9f8fdda3 100644 --- a/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.cxx +++ b/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.cxx @@ -252,9 +252,10 @@ int Fl_Cocoa_Window_Driver::scroll(int src_x, int src_y, int src_w, int src_h, i { CGImageRef img = CGImage_from_window_rect(src_x, src_y, src_w, src_h); if (img) { - float s = Fl_Surface_Device::surface()->driver()->scale(); - ((Fl_Quartz_Graphics_Driver*)fl_graphics_driver)->draw_CGImage(img, - dest_x, dest_y, lround(s*src_w), lround(s*src_h), 0, 0, src_w, src_h); + // the current surface is generally the display, but is an Fl_Image_Surface when scrolling an Fl_Overlay_Window + Fl_Quartz_Graphics_Driver *qgd = (Fl_Quartz_Graphics_Driver*)Fl_Surface_Device::surface()->driver(); + float s = qgd->scale(); + qgd->draw_CGImage(img, dest_x, dest_y, lround(s*src_w), lround(s*src_h), 0, 0, src_w, src_h); CFRelease(img); } return 0;