Optimize Linux get high DPI code

This commit is contained in:
vcaesar 2021-11-26 18:07:08 -04:00
parent 8a7d6a1306
commit 34fc3ffb38

View File

@ -56,17 +56,19 @@ double sys_scale() {
// https://github.com/glfw/glfw/issues/1019#issuecomment-302772498 // https://github.com/glfw/glfw/issues/1019#issuecomment-302772498
char *rms = XResourceManagerString(dpy); char *rms = XResourceManagerString(dpy);
if (rms) { if (rms) {
XrmDatabase db; XrmDatabase db = XrmGetStringDatabase(rms);
if (db) {
XrmValue value; XrmValue value;
char *type = NULL; char *type = NULL;
XrmInitialize(); /* Need to initialize the DB before calling Xrm* functions */ if (XrmGetResource(db, "Xft.dpi", "String", &type, &value)) {
db = XrmGetStringDatabase(rms);
if (XrmGetResource(db, "Xft.dpi", "String", &type, &value) == True) {
if (value.addr) { if (value.addr) {
xres = atof(value.addr); xres = atof(value.addr);
} }
} }
XrmDestroyDatabase(db);
}
} }
XCloseDisplay (dpy); XCloseDisplay (dpy);