High DPI issues

Teo Mrnjavac teo at kde.org
Mon May 19 12:24:30 UTC 2014


Hello list,

I've done a bit of research on DPI-related issues, which become particularly 
evident on high-DPI displays. As far as I can tell, right now Plasma does some 
scaling, which is mostly based on font size and QPaintDevice::physicalDpiX().
While this is all fine, I'd like to point out two issues.
1) physicalDpiX is unreliable on X. Actually, anything X reports is unreliable 
because of [1] and [2]: the only situation where X reports the correct DPI is 
with Nvidia proprietary drivers, and even then as far as I can tell the DPI is 
only valid for the primary display.
2) Plasma has a way to scale UI elements, but that's not always the case with 
QWidget-based applications. The most noticeable issue is window sizing, where 
e.g. on my 215ppi 15" display the systemsettings main window starts at less 
than 1/8 of the total display area, and with properly scaled icons it shows 
only 3 entries at a time. So a way is needed to compute scaled pixel sizes 
based on the DPI setting.

The whole deal with scaling based on DPI value is easy to implement but 
conceptually *hard*.
For starters, there is no single correct DPI value: what about multi-head 
setups? What's the correct DPI when you connect a projector? X gives up and 
reports 96ppi for compatibility reasons, but I believe that in 2014 we cannot 
afford to not do scaling any more, and the fact that X intentionally 
misreports screen geometry makes it much harder for anybody further up the 
stack to get a good DPI value - except with Nvidia in some situations.

There is however something we can do. As far as I can tell, Xft gets its 
initial DPI value from X, but we also already have a way to force it to 
another value in the Fonts KCM. Therefore, while we have to live with the fact 
that X will usually tell Xft something wrong, at least we can let the user 
override it with a better setting.

What I'm proposing is moving the part of plasma-
framework/src/declarativeimports/core/units.{h,cpp} that computes the scaling 
ratio over to a new class in KGuiAddons (or wherever else you'd prefer it, 
suggestions accepted), and adding some heuristics to the calculation so that 
we try to avoid relying on that nasty 96ppi value from X. This way, both 
Plasma and QWidget-based applications would benefit from the same heuristics 
and the same DPI setting in the KCM, and could simply ask for a scaling 
factor.

If there's consensus I'd like to proceed with this soonish, but in order to do 
it right I'd appreciate some feedback and suggestions.

[1] https://bugs.freedesktop.org/show_bug.cgi?id=23705
[2] https://bugs.freedesktop.org/show_bug.cgi?id=41115

Cheers,
-- 
Teo Mrnjavac
http://teom.org | teo at kde.org


More information about the Plasma-devel mailing list