Browse Source

sokol_app.h x11: assume dpi=96 if querying dpi value fails (fixes #755)

Andre Weissflog 2 năm trước cách đây
mục cha
commit
7f261ae382
1 tập tin đã thay đổi với 7 bổ sung0 xóa
  1. 7 0
      sokol_app.h

+ 7 - 0
sokol_app.h

@@ -10276,6 +10276,7 @@ _SOKOL_PRIVATE void _sapp_x11_query_system_dpi(void) {
              consistent user experience (matches Qt, Gtk, etc), although not
              always the most accurate one
     */
+    bool dpi_ok = false;
     char* rms = XResourceManagerString(_sapp.x11.display);
     if (rms) {
         XrmDatabase db = XrmGetStringDatabase(rms);
@@ -10285,11 +10286,17 @@ _SOKOL_PRIVATE void _sapp_x11_query_system_dpi(void) {
             if (XrmGetResource(db, "Xft.dpi", "Xft.Dpi", &type, &value)) {
                 if (type && strcmp(type, "String") == 0) {
                     _sapp.x11.dpi = atof(value.addr);
+                    dpi_ok = true;
                 }
             }
             XrmDestroyDatabase(db);
         }
     }
+    // fallback if querying DPI had failed: assume the standard DPI 96.0f
+    if (!dpi_ok) {
+        _sapp.x11.dpi = 96.0f;
+        SAPP_LOG("sokol_app.h: failed to system dpi value, assuming default 96.0");
+    }
 }
 
 #if defined(_SAPP_GLX)