Lagrange [work/v1.10]

Fixed running under KMSDRM video driver on Linux

=> fbad0cc670fc12f135af2a60f4af2aa9bd93cf9c

diff --git a/src/app.c b/src/app.c
index bf781c03..f8dc5697 100644
--- a/src/app.c
+++ b/src/app.c
@@ -122,6 +122,7 @@ struct Impl_App {
     uint32_t     lastTickerTime;
     uint32_t     elapsedSinceLastTicker;
     iBool        isRunning;
+    iBool        isRunningUnderWindowSystem;
 #if defined (LAGRANGE_ENABLE_IDLE_SLEEP)
     iBool        isIdling;
     uint32_t     lastEventTime;
@@ -626,6 +627,12 @@ static iBool hasCommandLineOpenableScheme_(const iRangecc uri) {
 }
 
 static void init_App_(iApp *d, int argc, char **argv) {
+#if defined (iPlatformLinux)
+    d->isRunningUnderWindowSystem = !iCmpStr(SDL_GetCurrentVideoDriver(), "x11") ||
+                                    !iCmpStr(SDL_GetCurrentVideoDriver(), "wayland");
+#else
+    d->isRunningUnderWindowSystem = iTrue;
+#endif
     init_CommandLine(&d->args, argc, argv);
     /* Where was the app started from? We ask SDL first because the command line alone is
        not a reliable source of this information, particularly when it comes to different
@@ -749,7 +756,8 @@ static void init_App_(iApp *d, int argc, char **argv) {
     mulfv_I2(&d->initialWindowRect.size, desktopDPI_Win32());
 #endif
 #if defined (iPlatformLinux)
-    /* Scale by the primary (?) monitor DPI. */ {
+    /* Scale by the primary (?) monitor DPI. */ 
+    if (isRunningUnderWindowSystem_App()) {
         float vdpi;
         SDL_GetDisplayDPI(0, NULL, NULL, &vdpi);
         const float factor = vdpi / 96.0f;
@@ -1582,6 +1590,10 @@ enum iAppDeviceType deviceType_App(void) {
 #endif
 }
 
+iBool isRunningUnderWindowSystem_App(void) {
+    return app_.isRunningUnderWindowSystem;
+}
+
 iGmCerts *certs_App(void) {
     return app_.certs;
 }
diff --git a/src/app.h b/src/app.h
index 5d1d42e1..55bec5a6 100644
--- a/src/app.h
+++ b/src/app.h
@@ -87,6 +87,8 @@ iBool               isLandscape_App     (void);
 iLocalDef iBool     isPortrait_App      (void) { return !isLandscape_App(); }
 enum iAppDeviceType deviceType_App      (void);
 iLocalDef iBool     isPortraitPhone_App (void) { return isPortrait_App() && deviceType_App() == phone_AppDeviceType; }
+iBool               isRunningUnderWindowSystem_App  (void);
+
 iGmCerts *          certs_App           (void);
 iVisited *          visited_App         (void);
 iBookmarks *        bookmarks_App       (void);
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
 }
 
Proxy Information
Original URL
gemini://git.skyjake.fi/lagrange/work%2Fv1.10/cdiff/fbad0cc670fc12f135af2a60f4af2aa9bd93cf9c
Status Code
Success (20)
Meta
text/gemini; charset=utf-8
Capsule Response Time
65.684674 milliseconds
Gemini-to-HTML Time
0.277425 milliseconds

This content has been proxied by September (ba2dc).