From 7dc67a1f9f338fd76bbfebaab946313b6121b226 Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Sat, 8 Aug 2020 18:43:55 +0200 Subject: [PATCH] making GetDPIScaleFactor virtual, adding macOS direct impl --- include/wx/osx/window.h | 1 + include/wx/window.h | 2 +- src/osx/window_osx.cpp | 9 ++++++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/include/wx/osx/window.h b/include/wx/osx/window.h index 76ec9bdb1c..e327b0a55b 100644 --- a/include/wx/osx/window.h +++ b/include/wx/osx/window.h @@ -121,6 +121,7 @@ public: #endif // wxUSE_HOTKEY virtual wxSize GetDPI() const wxOVERRIDE; + virtual double GetDPIScaleFactor() const wxOVERRIDE; #if wxUSE_DRAG_AND_DROP virtual void SetDropTarget( wxDropTarget *dropTarget ) wxOVERRIDE; diff --git a/include/wx/window.h b/include/wx/window.h index 68e91ad291..1c3cc3d759 100644 --- a/include/wx/window.h +++ b/include/wx/window.h @@ -537,7 +537,7 @@ public: // Return the ratio of the DPI used by this window to the standard DPI, // e.g. 1 for standard DPI screens and 2 for "200% scaling". - double GetDPIScaleFactor() const; + virtual double GetDPIScaleFactor() const; // return the size of the left/right and top/bottom borders in x and y // components of the result respectively diff --git a/src/osx/window_osx.cpp b/src/osx/window_osx.cpp index 4e5db615b2..65dd5d2fed 100644 --- a/src/osx/window_osx.cpp +++ b/src/osx/window_osx.cpp @@ -2629,6 +2629,12 @@ wxSize wxWindowMac::OSXMakeDPIFromScaleFactor(double scaleFactor) } wxSize wxWindowMac::GetDPI() const +{ + return OSXMakeDPIFromScaleFactor(GetDPIScaleFactor()); +} + +// on mac ContentScale and DPIScale are identical +double wxWindowMac::GetDPIScaleFactor() const { double scaleFactor; if ( wxNonOwnedWindow* tlw = MacGetTopLevelWindow() ) @@ -2636,9 +2642,10 @@ wxSize wxWindowMac::GetDPI() const else scaleFactor = wxOSXGetMainScreenContentScaleFactor(); - return OSXMakeDPIFromScaleFactor(scaleFactor); + return scaleFactor; } + // // wxWidgetImpl //