Last active
August 29, 2015 14:12
-
-
Save sapier/95e7c31c69419502977e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float getDisplayDensity() | |
{ | |
const char* current_display = getenv("DISPLAY"); | |
if (current_display == 0) | |
return g_settings->getFloat("screen_dpi")/96.0; | |
Display * x11display = XOpenDisplay(current_display); | |
float dpi_height = floor(DisplayHeight(x11display, 0) / (DisplayHeightMM(x11display, 0) * 0.039370) + 0.5); | |
float dpi_width = floor(DisplayWidth(x11display, 0) / (DisplayWidthMM(x11display, 0) * 0.039370) +0.5); | |
XCloseDisplay(x11display); | |
errorstream << "DPIH: " << dpi_height << " DPIW: " << dpi_width << std::endl; | |
return (std::max(dpi_height,dpi_width) / 96.0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment