Browse Source

Platform: account for KDE unsetting Xft.dpi if display scaling is 100%.

Without this it would fall back to physical DPI, i.e. taken from the
display dimensions. Which sometimes *is* correct, but often isn't what
the users want -- it's common to have a high DPI screen on a laptop
(such as a full HD on a 15.6") but still only use 100% scaling even
though it's a bit tiny. And often it's completely incorrect, depending
on how accidentally misconfigured the system is, and the users won't
even know because almost nothing uses the physical DPI value by default.
pull/638/head
Vladimír Vondruš 2 years ago
parent
commit
68174c6bc4
  1. 12
      src/Magnum/Platform/Implementation/DpiScaling.cpp

12
src/Magnum/Platform/Implementation/DpiScaling.cpp

@ -128,6 +128,18 @@ Float x11DpiScaling() {
return scaling;
}
}
/* On KDE, if the display scaling is set to 100%, the Xft.dpi property
isn't even present. Not nice. In that case just assume 100% scaling.
A similar change was done in GLFW:
https://github.com/glfw/glfw/commit/399c082033945f4f3c1a993d9d4b80b85c66172e
"All of this is terrible please send help."
I'm being extra strict here and do this only if it looks like it's a
KDE session. There are other known cases where this fails, like when
running on a Librem 5 phone, but I have no idea how to fix these
yet. */
if(std::getenv("KDE_SESSION_UID"))
return 1.0f;
}
Warning{} << "Platform: can't get Xft.dpi property for virtual DPI scaling, falling back to physical DPI";

Loading…
Cancel
Save