SendSystemInfo: Only get the scaling on Win, not on mac or Linux

This commit is contained in:
Lukas Matena 2021-10-06 15:48:35 +02:00
parent 56c3ea0261
commit f72a5cf1e7

View File

@ -398,20 +398,17 @@ static std::string generate_system_info_json()
pt::ptree monitors_node; pt::ptree monitors_node;
for (int i=0; i<int(wxDisplay::GetCount()); ++i) { for (int i=0; i<int(wxDisplay::GetCount()); ++i) {
wxDisplay display(i); wxDisplay display(i);
double scaling = -1.;
#if wxCHECK_VERSION(3, 1, 2) // we have wxDisplag::GetPPI
int std_ppi = 96;
#ifdef __WXOSX__ // see impl of wxDisplay::GetStdPPIValue from 3.1.5
std_ppi = 72;
#endif
scaling = double(display.GetPPI().GetWidth()) / std_ppi;
#endif
pt::ptree monitor_node; // Create an unnamed node containing the value pt::ptree monitor_node; // Create an unnamed node containing the value
monitor_node.put("width", display.GetGeometry().GetWidth()); monitor_node.put("width", display.GetGeometry().GetWidth());
monitor_node.put("height", display.GetGeometry().GetHeight()); monitor_node.put("height", display.GetGeometry().GetHeight());
// Only get the scaling on Win, it is not reliable on other platforms.
#if defined(_WIN32) && wxCHECK_VERSION(3, 1, 2)
double scaling = display.GetPPI().GetWidth() / 96.;
std::stringstream ss; std::stringstream ss;
ss << std::setprecision(3) << scaling; ss << std::setprecision(3) << scaling;
monitor_node.put("scaling", ss.str() ); monitor_node.put("scaling", ss.str() );
#endif
monitors_node.push_back(std::make_pair("", monitor_node)); monitors_node.push_back(std::make_pair("", monitor_node));
} }
hw_node.add_child("Monitors", monitors_node); hw_node.add_child("Monitors", monitors_node);