-
-
Save Zeno-/1d01769ee969ebeec50c 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
static float getDisplayDensity_init() | |
{ | |
const char* current_display = getenv("DISPLAY"); | |
if (current_display != NULL) { | |
Display * x11display = XOpenDisplay(current_display); | |
if (x11display != NULL) { | |
/* try x direct */ | |
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); | |
return std::max(dpi_height,dpi_width) / 96.0; | |
} | |
} | |
/* return manually specified dpi */ | |
return g_settings->getFloat("screen_dpi")/96.0; | |
} | |
static float cached_display_density = getDisplayDensity_init(); | |
float getDisplayDensity() | |
{ | |
return cached_display_density; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment