From fbad0cc670fc12f135af2a60f4af2aa9bd93cf9c Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Sun, 29 Aug 2021 15:52:06 +0300 Subject: Fixed running under KMSDRM video driver on Linux SDL2 works fine without a window system, but it seems the DPI-querying API will crash so let's not call that. Should still add command line options to control the screen resolution, i.e., overriding the window size. --- src/ui/window.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/ui/window.c') diff --git a/src/ui/window.c b/src/ui/window.c index ebb4d1a8..f8391ed9 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -278,11 +278,14 @@ static float displayScale_Window_(const iWindow *d) { iUnused(d); return desktopDPI_Win32(); #else - float vdpi = 0.0f; - SDL_GetDisplayDPI(SDL_GetWindowDisplayIndex(d->win), NULL, NULL, &vdpi); -// printf("DPI: %f\n", vdpi); - const float factor = vdpi / baseDPI_Window / pixelRatio_Window_(d); - return iMax(1.0f, factor); + if (isRunningUnderWindowSystem_App()) { + float vdpi = 0.0f; + SDL_GetDisplayDPI(SDL_GetWindowDisplayIndex(d->win), NULL, NULL, &vdpi); +// printf("DPI: %f\n", vdpi); + const float factor = vdpi / baseDPI_Window / pixelRatio_Window_(d); + return iMax(1.0f, factor); + } + return 1.0f; #endif } -- cgit v1.2.3