Lagrange [work/v1.10]

Linux: Use SDL to query display monitor DPI value

=> b43b9a6b81e572556800a82a5bda2befc578c4cc

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)
+    /* Scale by the primary (?) monitor DPI. */ {
+        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)
+    float vdpi = 0.0f;
+    SDL_GetDisplayDPI(SDL_GetWindowDisplayIndex(d->win), NULL, NULL, &vdpi);
+    const float factor = vdpi / 96.0f;
+    return iMax(1.0f, factor);
+#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)
+    SDL_SetWindowMinimumSize(d->win, minSize.x * d->pixelRatio, minSize.y * d->pixelRatio);
     /* 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
Proxy Information
Original URL
gemini://git.skyjake.fi/lagrange/work%2Fv1.10/cdiff/b43b9a6b81e572556800a82a5bda2befc578c4cc
Status Code
Success (20)
Meta
text/gemini; charset=utf-8
Capsule Response Time
58.654062 milliseconds
Gemini-to-HTML Time
0.303528 milliseconds

This content has been proxied by September (ba2dc).