Bug 362767 - High DPI is messed up after Qt 5.6 update
Summary: High DPI is messed up after Qt 5.6 update
Status: RESOLVED FIXED
Alias: None
Product: neon
Classification: KDE Neon
Component: general (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Neon Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-05-06 23:24 UTC by Greg Varsanyi
Modified: 2016-08-22 18:12 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Greg Varsanyi 2016-05-06 23:24:40 UTC
Screen scaling (kcm_kscreen) still sets the deprecated QT_DEVICE_PIXEL_RATIO, the new QT_AUTO_SCREEN_SCALE_FACTOR confuses kwin_x11 and plasmashell really bad.

I wonder if this has to do with packages still being compiled against Qt 5.5.1

Reproducible: Always

Steps to Reproduce:
1. Grab a high DPI screen
2. Set screen scaling (Display Configuration > Screen Scaling > x2)
3. Log out and back in

or

1. Update to latest with Qt 5.6 on a system with high DPI configured.

Actual Results:  
case #1 (using QT_DEVICE_PIXEL_RATIO=2)
double (4x instead of 2x scaled) plasma parts and apps

case #2 (unset QT_DEVICE_PIXEL_RATIO)
some items are not sized up (fonts define minimum size), icons are too small (1x instead of 2x)

case #3 (using QT_AUTO_SCREEN_SCALE_FACTOR=1)
kwin_x11 provides small (1x) decorations, has placement issues and changes the height of all windows to the minimum possible

Expected Results:  
Scale to 2x consistantly
In an ideal word: make use of Qt 5.6 automatic screen scale factor

I realize this is partly of a Plasma development issue, but setting the environment variables and compiling against Qt 5.6 might be a packaging thing.
Comment 1 Harald Sitter 2016-05-08 20:42:55 UTC
Which edition of neon are you on? I can poke some rebuilds so we'll know for sure.
Comment 2 Greg Varsanyi 2016-05-08 21:20:42 UTC
(In reply to Harald Sitter from comment #1)
> Which edition of neon are you on? I can poke some rebuilds so we'll know for
> sure.

dev/stable

btw, new packages seem to be compiled against qt 5.6 but all issues remain the same.

Unless there is a tricky combination of ENV vars I haven't figured out, I'm afraid this is a development issue where deprecated logic/code has to be updated all across the code base to play better with Qt 5.6 high dpi logic.
Comment 3 Harald Sitter 2016-05-08 22:34:24 UTC
Adding David and Kai Uwe as they might have input on this seeing as they both have hidpi devices.

Any thoughts?
Comment 4 Harald Sitter 2016-05-09 10:46:34 UTC
I poked rebuilds of plasma-workspace and kwin as kwin should have compile-time ifdefs for Qt 5.6. Please check back when build 18 here is done and confirm that this fixes the issue:

http://build.neon.kde.org/view/stable/job/xenial_stable_plasma_plasma-workspace/
Comment 5 David Edmundson 2016-05-09 10:58:09 UTC
For Case #1:
 - qt now scales up font DPI for some reason, you can counter that by explicitly also setting
QT_FONT_DPI to be half/double (not sure which way round it is) 

For Case #3

Since Plasma 5.5 we do have code to disable internal high DPI managing on Qt5.6

However, it requires kwin/plasma also be *compiled* with Qt5.6

#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
    QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling);
#endif
Comment 6 Kai Uwe Broulik 2016-05-09 11:10:56 UTC
Qt still takes into account QT_DEVICE_PIXEL_RATIO in 5.6 and does not merge it with the new one because the new one is in the core whereas the old is in the QPA and so both scale at the same time, a bugreport I opened was (of course...) closed as invalid because how dare we use this feature in the first place.

Also I recall Qt still doing weird things even if the app opts out of scaling, so perhaps we need to go down the qunsetenv route there as well.
Comment 7 Harald Sitter 2016-05-09 11:26:51 UTC
list of AA_DisableHighDpiScaling usage for the record
https://lxr.kde.org/search?_filestring=&_string=Qt%3A%3AAA_DisableHighDpiScaling
Comment 8 Greg Varsanyi 2016-05-09 15:34:42 UTC
(In reply to David Edmundson from comment #5)
> For Case #1:
>  - qt now scales up font DPI for some reason, you can counter that by
> explicitly also setting
> QT_FONT_DPI to be half/double (not sure which way round it is) 
> 
> For Case #3
> 
> Since Plasma 5.5 we do have code to disable internal high DPI managing on
> Qt5.6
> 
> However, it requires kwin/plasma also be *compiled* with Qt5.6
> 
> #if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
>     QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling);
> #endif

playing with QT_FONT_DPI gets me the closest.
a combination of QT_FONT_DPI=96 and QT_DEVICE_PIXEL_RATIO=2 (and not setting/unsetting any new Qt 5.6 env vars) gives me consistent look and feel across the *apps*, but not plasmashell and kwin - they go half sized.
it would seem that plasmashell and kwin read the font dpi value and apply that literally as pixels.
that can also be mitigated by starting these two (and only these two) with QT_FONT_DPI=192.

So, using a deprecated and a falsified env var - with some exception handling - mostly gets us there.

--

i wonder why did you guys decided to disable the native scaling.
Comment 9 Weng Xuetian 2016-05-09 15:51:54 UTC
IIRC, though QT_DEVICE_PIXEL_RATIO is still there, it's not doing the exact same thing as it is in 5.5 . For now I'm using a combination of QT_AUTO_SCREEN_SCALE_FACTOR and QT_SCREEN_SCALE_FACTORS to achieve the same effect.

And kwin/plasma shouldn't be affected since they are not using it anyway, if you found kwin/plasma is scaled, probably your distro need to compile kwin/plasma against Qt 5.6 to make some qt5.6 compile time specific check work.
Comment 10 Greg Varsanyi 2016-05-09 17:57:41 UTC
(In reply to Weng Xuetian from comment #9)
> IIRC, though QT_DEVICE_PIXEL_RATIO is still there, it's not doing the exact
> same thing as it is in 5.5 . For now I'm using a combination of
> QT_AUTO_SCREEN_SCALE_FACTOR and QT_SCREEN_SCALE_FACTORS to achieve the same
> effect.

what combination do you use? and how do you make it system wide exactly?

> And kwin/plasma shouldn't be affected since they are not using it anyway, if
> you found kwin/plasma is scaled, probably your distro need to compile
> kwin/plasma against Qt 5.6 to make some qt5.6 compile time specific check
> work.

plasma and kwin seem to use the font size, around the idea of `1 line height in rendered px = perceivedDPI / 96 * referenceFontBoundaryHeight` where perceivedDPI seems to come from QT_FONT_DPI / fonts.conf DPI value / X.org global DPI

--

how do I check what Qt version are plasmashell or kwin_x11 compiled against? for apps it's shown on the about/version panel, but `plasmashell -v` only gives me plasma version.
Comment 11 Greg Varsanyi 2016-08-22 18:12:29 UTC
A lot has changed since I opened this ticket. At this point (Qt 5.7) defaults work well mostly, no need for extra trickery with env variables and such.

closing as fixed.