Fall back to display-independent PPI in wxGTK
If we can't determine the display-specific PPI value, use the global one which seems to be always available (and always equal to 96*96 in my testing -- but this is what previous versions of wxWidgets returned, so it's still better than nothing).
This commit is contained in:
@@ -231,6 +231,7 @@ public:
|
|||||||
#if GTK_CHECK_VERSION(3,10,0)
|
#if GTK_CHECK_VERSION(3,10,0)
|
||||||
virtual double GetScaleFactor() const wxOVERRIDE;
|
virtual double GetScaleFactor() const wxOVERRIDE;
|
||||||
#endif // GTK+ 3.10
|
#endif // GTK+ 3.10
|
||||||
|
virtual wxSize GetPPI() const wxOVERRIDE;
|
||||||
virtual wxSize GetSizeMM() const wxOVERRIDE;
|
virtual wxSize GetSizeMM() const wxOVERRIDE;
|
||||||
|
|
||||||
#if wxUSE_DISPLAY
|
#if wxUSE_DISPLAY
|
||||||
@@ -312,6 +313,24 @@ double wxDisplayImplGTK::GetScaleFactor() const
|
|||||||
}
|
}
|
||||||
#endif // GTK+ 3.10
|
#endif // GTK+ 3.10
|
||||||
|
|
||||||
|
wxSize wxDisplayImplGTK::GetPPI() const
|
||||||
|
{
|
||||||
|
// Try the base class version which uses our GetSizeMM() and returns
|
||||||
|
// per-display PPI value if it works.
|
||||||
|
wxSize ppi = wxDisplayImpl::GetPPI();
|
||||||
|
|
||||||
|
if ( !ppi.x || !ppi.y )
|
||||||
|
{
|
||||||
|
// But if it didn't work, fall back to the global DPI value common to
|
||||||
|
// all displays -- this is still better than nothing and more
|
||||||
|
// compatible with the previous wxWidgets versions.
|
||||||
|
ppi = ComputePPI(gdk_screen_width(), gdk_screen_height(),
|
||||||
|
gdk_screen_width_mm(), gdk_screen_height_mm());
|
||||||
|
}
|
||||||
|
|
||||||
|
return ppi;
|
||||||
|
}
|
||||||
|
|
||||||
wxSize wxDisplayImplGTK::GetSizeMM() const
|
wxSize wxDisplayImplGTK::GetSizeMM() const
|
||||||
{
|
{
|
||||||
wxSize sizeMM;
|
wxSize sizeMM;
|
||||||
|
Reference in New Issue
Block a user