summaryrefslogtreecommitdiff
path: root/src/porting.cpp
diff options
context:
space:
mode:
authorkwolekr <kwolekr@minetest.net>2015-07-02 23:14:30 -0400
committerkwolekr <kwolekr@minetest.net>2015-07-02 23:14:30 -0400
commit7b171ea2be0e476d7cdc9300b53ba86a9f694161 (patch)
treede1768db2a4dce40738ed96248f29f7c923c527b /src/porting.cpp
parent0a0378fecef5c6b4be6d034d8bced2a1568dde81 (diff)
downloadminetest-7b171ea2be0e476d7cdc9300b53ba86a9f694161.tar.gz
minetest-7b171ea2be0e476d7cdc9300b53ba86a9f694161.tar.bz2
minetest-7b171ea2be0e476d7cdc9300b53ba86a9f694161.zip
Fix code style from recent commits and add misc. optimizations
Diffstat (limited to 'src/porting.cpp')
-rw-r--r--src/porting.cpp24
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;