diff --git a/src/osx/cocoa/window.mm b/src/osx/cocoa/window.mm index 62fb443d5e..80a0838032 100644 --- a/src/osx/cocoa/window.mm +++ b/src/osx/cocoa/window.mm @@ -2648,7 +2648,10 @@ void wxWidgetCocoaImpl::SetVisibility( bool visible ) double wxWidgetCocoaImpl::GetContentScaleFactor() const { NSWindow* tlw = [m_osxView window]; - return [tlw backingScaleFactor]; + if ( tlw ) + return [tlw backingScaleFactor]; + else + return wxOSXGetMainScreenContentScaleFactor(); } // ---------------------------------------------------------------------------- diff --git a/src/osx/window_osx.cpp b/src/osx/window_osx.cpp index 65dd5d2fed..46fa8188a1 100644 --- a/src/osx/window_osx.cpp +++ b/src/osx/window_osx.cpp @@ -2636,13 +2636,7 @@ wxSize wxWindowMac::GetDPI() const // on mac ContentScale and DPIScale are identical double wxWindowMac::GetDPIScaleFactor() const { - double scaleFactor; - if ( wxNonOwnedWindow* tlw = MacGetTopLevelWindow() ) - scaleFactor = tlw->GetContentScaleFactor(); - else - scaleFactor = wxOSXGetMainScreenContentScaleFactor(); - - return scaleFactor; + return GetContentScaleFactor(); }