diff --git a/src/ui/window.c b/src/ui/window.c

index e1266357..bda645f7 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. */

#include "stb_image.h"

#include "stb_image_resize.h"



-#include <stdlib.h>

-#include <string.h>

-

static iWindow *theWindow_ = NULL;



#if defined (iPlatformApple) || defined (iPlatformLinux)

@@ -1317,24 +1314,23 @@ static float pixelRatio_Window_(const iWindow *d) {

#endif



static float displayScale_Window_(const iWindow *d) {

- char* LAGRANGE_OVERRIDE_DPI = getenv("LAGRANGE_OVERRIDE_DPI");

-

- /* If LAGRANGE_OVERRIDE_DPI is not set, or is an empty string, ignore it. */

- if ((LAGRANGE_OVERRIDE_DPI != NULL) && (strnlen(LAGRANGE_OVERRIDE_DPI, 1) > 0)) {

- /* This if the user has set the env var, but it is not an int, atoi */

+ /* The environment variable LAGRANGE_OVERRIDE_DPI can be used to override the automatic

+ display DPI detection. If not set, or is an empty string, ignore it.

+ Note: the same value used for all displays. */

+ const char *LAGRANGE_OVERRIDE_DPI = getenv("LAGRANGE_OVERRIDE_DPI");

+ if (LAGRANGE_OVERRIDE_DPI && *LAGRANGE_OVERRIDE_DPI) {

+ /* If the user has set the env var, but it is not an int, atoi */

     /* will return 0, in which case we just guess and return 96 DPI.  */

- int env_dpi = atoi(LAGRANGE_OVERRIDE_DPI);

-

- if (env_dpi == 0) {

- fprintf(stderr, "WARNING: failed to parse LAGRANGE_OVERRIDE_DPI='%s', ignoring it\n", LAGRANGE_OVERRIDE_DPI);

- /* To avoid showing the window multiple times, overwrite

- * LAGRANGE_OVERRIDE_DPI with the empty string. */

- setenv("LAGRANGE_OVERRIDE_DPI", "", 1);

- } else {

- return ((float) env_dpi) / baseDPI_Window;

+ const int envDpi = atoi(LAGRANGE_OVERRIDE_DPI);

+ if (envDpi > 0) {

+ return ((float) envDpi) / baseDPI_Window;

     }

+ fprintf(stderr, "[Window] WARNING: failed to parse LAGRANGE_OVERRIDE_DPI='%s', "

+ "ignoring it\n", LAGRANGE_OVERRIDE_DPI);

+ /* To avoid showing the warning multiple times, overwrite

+ LAGRANGE_OVERRIDE_DPI with the empty string. */

+ setenv("LAGRANGE_OVERRIDE_DPI", "", 1);

 }

-

#if defined (iPlatformApple)

 iUnused(d);

 /* Apple UI sizes are fixed and only scaled by pixel ratio. */

Proxy Information
Original URL
gemini://git.skyjake.fi/lagrange/work%2Fv1.10/pcdiff/cb39c0a4ab368466d52816690587db81dad198f9
Status Code
Success (20)
Meta
text/plain
Capsule Response Time
59.420874 milliseconds
Gemini-to-HTML Time
1.534751 milliseconds

This content has been proxied by September (ba2dc).