Add wxDisplayImpl::GetScaleFactor() and implement it for wxGTK
We need to account for the scale factor under GTK+ (and, presumably, under macOS) to compute the correct PPI value as it must use the number of physical and not logical pixels.
This commit is contained in:
@@ -195,9 +195,7 @@ bool wxDisplay::ChangeMode(const wxVideoMode& mode)
|
||||
|
||||
wxSize wxDisplayImpl::GetPPI() const
|
||||
{
|
||||
const wxSize pixels = GetGeometry().GetSize();
|
||||
const wxSize mm = GetSizeMM();
|
||||
|
||||
if ( !mm.x || !mm.y )
|
||||
{
|
||||
// Physical size is unknown, return a special value indicating that we
|
||||
@@ -205,6 +203,10 @@ wxSize wxDisplayImpl::GetPPI() const
|
||||
return wxSize(0, 0);
|
||||
}
|
||||
|
||||
// We need physical pixels here, not logical ones returned by
|
||||
// GetGeometry(), to compute the real DPI.
|
||||
const wxSize pixels = GetGeometry().GetSize()*GetScaleFactor();
|
||||
|
||||
return wxSize(wxRound((pixels.x * inches2mm) / mm.x),
|
||||
wxRound((pixels.y * inches2mm) / mm.y));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user