diff options
Diffstat (limited to 'src/porting.cpp')
-rw-r--r-- | src/porting.cpp | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/src/porting.cpp b/src/porting.cpp index 29c82fe24..44f1fcff1 100644 --- a/src/porting.cpp +++ b/src/porting.cpp @@ -749,25 +749,23 @@ const char *getVideoDriverFriendlyName(irr::video::E_DRIVER_TYPE type) static float calcDisplayDensity() { - const char* current_display = getenv("DISPLAY"); + const char *current_display = getenv("DISPLAY"); if (current_display != NULL) { - Display * x11display = XOpenDisplay(current_display); + 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); + 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); + XCloseDisplay(x11display); - return std::max(dpi_height,dpi_width) / 96.0; - } + return std::max(dpi_height,dpi_width) / 96.0; } + } /* return manually specified dpi */ return g_settings->getFloat("screen_dpi")/96.0; |