Skip to content

Commit

Permalink
Make wxWindow::GetContentScaleFactor() work in wxGTK3
Browse files Browse the repository at this point in the history
This is a partial backport of f95fd11.

Also update ABI version information to use WXU_3.0.5 version for the new
wxWindow::GetContentScaleFactor() symbol.

Closes #1517
  • Loading branch information
ojwb authored and vadz committed Sep 4, 2019
1 parent 7266509 commit d0ab581
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
3 changes: 3 additions & 0 deletions include/wx/gtk/window.h
Expand Up @@ -90,6 +90,9 @@ class WXDLLIMPEXP_CORE wxWindowGTK : public wxWindowBase

virtual int GetCharHeight() const;
virtual int GetCharWidth() const;
#if defined __WXGTK3__
virtual double GetContentScaleFactor() const;
#endif

virtual void SetScrollbar( int orient, int pos, int thumbVisible,
int range, bool refresh = true );
Expand Down
14 changes: 14 additions & 0 deletions src/gtk/window.cpp
Expand Up @@ -3429,6 +3429,20 @@ void wxWindowGTK::DoGetTextExtent( const wxString& string,
txm.GetTextExtent(string, x, y, descent, externalLeading);
}

#ifdef __WXGTK3__
double wxWindowGTK::GetContentScaleFactor() const
{
double scaleFactor = 1;
#if GTK_CHECK_VERSION(3,10,0)
if (m_widget && gtk_check_version(3,10,0) == NULL)
{
scaleFactor = gtk_widget_get_scale_factor(m_widget);
}
#endif
return scaleFactor;
}
#endif

void wxWindowGTK::GTKDisableFocusOutEvent()
{
g_signal_handlers_block_by_func( m_focusWidget,
Expand Down
4 changes: 4 additions & 0 deletions version-script.in
Expand Up @@ -27,6 +27,7 @@
*wxSVGFileDCImpl*SetAxisOrientation*;
*wxSVGFileDCImpl*SetDeviceOrigin*;
*wxSVGFileDCImpl*SetLogicalOrigin*;
*wxWindow*GetContentScaleFactor*;
};

# public symbols added in 3.0.4 (please keep in alphabetical order):
Expand Down Expand Up @@ -64,5 +65,8 @@
# Explicitly mention this one as otherwise it would be caught by
# wxDataViewRenderer*FinishEditing wildcard in 3.0.3 above.
*wxDataViewRendererBase*FinishEditing*;
# This would otherwise match *wxWindow*GetContentScaleFactor*
# in 3.0.5 above.
*wxWindowBase*GetContentScaleFactor*;
*;
};

0 comments on commit d0ab581

Please sign in to comment.