diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-04-17 14:39:26 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-04-17 14:39:26 +0300 |
commit | 4b63d7afe9f009601667c6fc01c7d8ef092b8881 (patch) | |
tree | 6c6f9f2580ba9bcefb1ee35d1cf14d60669c2909 | |
parent | 0b2764367310a58b94e89c8797131eee1af0f96c (diff) |
Window: Cleanup
-rw-r--r-- | src/ui/window.c | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/src/ui/window.c b/src/ui/window.c index 60c1483d..79073baa 100644 --- a/src/ui/window.c +++ b/src/ui/window.c | |||
@@ -63,9 +63,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ | |||
63 | #include "stb_image.h" | 63 | #include "stb_image.h" |
64 | #include "stb_image_resize.h" | 64 | #include "stb_image_resize.h" |
65 | 65 | ||
66 | #include <stdlib.h> | ||
67 | #include <string.h> | ||
68 | |||
69 | static iWindow *theWindow_ = NULL; | 66 | static iWindow *theWindow_ = NULL; |
70 | 67 | ||
71 | #if defined (iPlatformApple) || defined (iPlatformLinux) | 68 | #if defined (iPlatformApple) || defined (iPlatformLinux) |
@@ -1360,24 +1357,23 @@ static float pixelRatio_Window_(const iWindow *d) { | |||
1360 | #endif | 1357 | #endif |
1361 | 1358 | ||
1362 | static float displayScale_Window_(const iWindow *d) { | 1359 | static float displayScale_Window_(const iWindow *d) { |
1363 | char* LAGRANGE_OVERRIDE_DPI = getenv("LAGRANGE_OVERRIDE_DPI"); | 1360 | /* The environment variable LAGRANGE_OVERRIDE_DPI can be used to override the automatic |
1364 | 1361 | display DPI detection. If not set, or is an empty string, ignore it. | |
1365 | /* If LAGRANGE_OVERRIDE_DPI is not set, or is an empty string, ignore it. */ | 1362 | Note: the same value used for all displays. */ |
1366 | if ((LAGRANGE_OVERRIDE_DPI != NULL) && (strnlen(LAGRANGE_OVERRIDE_DPI, 1) > 0)) { | 1363 | const char *LAGRANGE_OVERRIDE_DPI = getenv("LAGRANGE_OVERRIDE_DPI"); |
1367 | /* This if the user has set the env var, but it is not an int, atoi */ | 1364 | if (LAGRANGE_OVERRIDE_DPI && *LAGRANGE_OVERRIDE_DPI) { |
1365 | /* If the user has set the env var, but it is not an int, atoi */ | ||
1368 | /* will return 0, in which case we just guess and return 96 DPI. */ | 1366 | /* will return 0, in which case we just guess and return 96 DPI. */ |
1369 | int env_dpi = atoi(LAGRANGE_OVERRIDE_DPI); | 1367 | const int envDpi = atoi(LAGRANGE_OVERRIDE_DPI); |
1370 | 1368 | if (envDpi > 0) { | |
1371 | if (env_dpi == 0) { | 1369 | return ((float) envDpi) / baseDPI_Window; |
1372 | fprintf(stderr, "WARNING: failed to parse LAGRANGE_OVERRIDE_DPI='%s', ignoring it\n", LAGRANGE_OVERRIDE_DPI); | ||
1373 | /* To avoid showing the window multiple times, overwrite | ||
1374 | * LAGRANGE_OVERRIDE_DPI with the empty string. */ | ||
1375 | setenv("LAGRANGE_OVERRIDE_DPI", "", 1); | ||
1376 | } else { | ||
1377 | return ((float) env_dpi) / baseDPI_Window; | ||
1378 | } | 1370 | } |
1371 | fprintf(stderr, "[Window] WARNING: failed to parse LAGRANGE_OVERRIDE_DPI='%s', " | ||
1372 | "ignoring it\n", LAGRANGE_OVERRIDE_DPI); | ||
1373 | /* To avoid showing the warning multiple times, overwrite | ||
1374 | LAGRANGE_OVERRIDE_DPI with the empty string. */ | ||
1375 | setenv("LAGRANGE_OVERRIDE_DPI", "", 1); | ||
1379 | } | 1376 | } |
1380 | |||
1381 | #if defined (iPlatformApple) | 1377 | #if defined (iPlatformApple) |
1382 | iUnused(d); | 1378 | iUnused(d); |
1383 | /* Apple UI sizes are fixed and only scaled by pixel ratio. */ | 1379 | /* Apple UI sizes are fixed and only scaled by pixel ratio. */ |