use common contentScaleFactor also for DPI on macOS

and give a reasonable default for missing tlw
This commit is contained in:
Stefan Csomor
2020-08-14 15:52:48 +02:00
committed by Vadim Zeitlin
parent c346fd0321
commit 08a63c3b49
2 changed files with 5 additions and 8 deletions

View File

@@ -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();
}
// ----------------------------------------------------------------------------

View File

@@ -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();
}