From 7b171ea2be0e476d7cdc9300b53ba86a9f694161 Mon Sep 17 00:00:00 2001 From: kwolekr Date: Thu, 2 Jul 2015 23:14:30 -0400 Subject: Fix code style from recent commits and add misc. optimizations --- src/porting.cpp | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'src/porting.cpp') 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; -- cgit v1.2.3