From 6a820a8f9ab7095f3fb42e0641bf2043a8eaf658 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 14 Aug 2020 14:53:41 +0200 Subject: [PATCH] Implement GetDPIScaleFactor() more efficiently in wxGTK Don't pass via wxDisplay, but use gtk_widget_get_scale_factor() (almost) directly instead. --- include/wx/gtk/window.h | 1 + src/gtk/window.cpp | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/include/wx/gtk/window.h b/include/wx/gtk/window.h index 9ca1202da1..9ec33b88ab 100644 --- a/include/wx/gtk/window.h +++ b/include/wx/gtk/window.h @@ -97,6 +97,7 @@ public: virtual int GetCharHeight() const wxOVERRIDE; virtual int GetCharWidth() const wxOVERRIDE; virtual double GetContentScaleFactor() const wxOVERRIDE; + virtual double GetDPIScaleFactor() const wxOVERRIDE; virtual void SetScrollbar( int orient, int pos, int thumbVisible, int range, bool refresh = true ) wxOVERRIDE; diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 4e33c1ff06..e7c8ecbe39 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -4363,6 +4363,13 @@ double wxWindowGTK::GetContentScaleFactor() const return scaleFactor; } +double wxWindowGTK::GetDPIScaleFactor() const +{ + // Under GTK 3 DPI scale factor is the same as content scale factor, while + // under GTK 2 both are always 1, so they're still the same. + return GetContentScaleFactor(); +} + void wxWindowGTK::GTKDisableFocusOutEvent() { g_signal_handlers_block_by_func( m_focusWidget,