From b43b9a6b81e572556800a82a5bda2befc578c4cc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jaakko=20Ker=C3=A4nen?= jaakko.keranen@iki.fi
Date: Tue, 2 Feb 2021 15:01:01 +0200
Subject: [PATCH 1/1] Linux: Use SDL to query display monitor DPI value
IssueID #133
src/app.c | 8 ++++++++
src/ui/window.c | 10 ++++++++--
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/src/app.c b/src/app.c
index f44fdf4f..a2d80bf2 100644
--- a/src/app.c
+++ b/src/app.c
@@ -373,6 +373,14 @@ static void init_App_(iApp *d, int argc, char **argv) {
#if defined (iPlatformMsys)
/* Must scale by UI scaling factor. */
mulfv_I2(&d->initialWindowRect.size, desktopDPI_Win32());
+#endif
+#if defined (iPlatformLinux)
float vdpi;
SDL_GetDisplayDPI(0, NULL, NULL, &vdpi);
const float factor = vdpi / 96.0f;
mulfv_I2(&d->initialWindowRect.size, iMax(factor, 1.0f));
#endif
init_Prefs(&d->prefs);
setCStr_String(&d->prefs.downloadDir, downloadDir_App_);
diff --git a/src/ui/window.c b/src/ui/window.c
index 8df92706..f8123a17 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -685,7 +685,12 @@ static float pixelRatio_Window_(const iWindow *d) {
#if defined (iPlatformMsys)
iUnused(d);
return desktopDPI_Win32();
-#else
+#elif defined (iPlatformLinux)
+#else
int dx, x;
SDL_GetRendererOutputSize(d->render, &dx, NULL);
SDL_GetWindowSize(d->win, &x, NULL);
@@ -764,6 +769,7 @@ void init_Window(iWindow *d, iRect rect) {
useExecutableIconResource_SDLWindow(d->win);
#endif
#if defined (iPlatformLinux)
/* Load the window icon. */ {
int w, h, num;
const iBlock *icon = &imageLagrange64_Embedded;
@@ -1033,7 +1039,7 @@ iInt2 rootSize_Window(const iWindow *d) {
}
iInt2 coord_Window(const iWindow *d, int x, int y) {
-#if defined (iPlatformMsys)
+#if defined (iPlatformMsys) || defined (iPlatformLinux)
/* On Windows, surface coordinates are in pixels. */
return init_I2(x, y);
#else
--
2.25.1
text/plain
This content has been proxied by September (ba2dc).