Bug 372046 - plasma5 show tiny icons in HiDPI screens
Summary: plasma5 show tiny icons in HiDPI screens
Status: RESOLVED INTENTIONAL
Alias: None
Product: plasmashell
Classification: Plasma
Component: general (show other bugs)
Version: 5.8.3
Platform: Other Linux
: NOR normal
Target Milestone: 1.0
Assignee: David Edmundson
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-11-03 22:07 UTC by Giuseppe Ghibò
Modified: 2016-11-06 15:18 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
don't force disabling automatic scaling (461 bytes, patch)
2016-11-03 22:07 UTC, Giuseppe Ghibò
Details
patch equivalent to original behaviour of QT_AUTO_SCREEN_SCALE_FACTOR=0 (1.25 KB, patch)
2016-11-05 01:44 UTC, Giuseppe Ghibò
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Giuseppe Ghibò 2016-11-03 22:07:52 UTC
Created attachment 102018 [details]
don't force disabling automatic scaling

When plasma5 runs in a HiDPI screen (e.g. a 4k screen with 3820x2160 pixels of resolution), and the screen DPI is set at the proper values in X11 (e.g. using DisplaySize in xorg.conf or forcing the -dpi argument in either xrandr or Xorg executable), the icons aren't scaled proportionally but remains super-tiny, and thus almost unreadable. The same happens to widgets. The higher is the resolution, the smaller and unbalanced are the icons. For instance for a 4k monitor at 15.6" you'll have near to 282 dpi, which is almost 3 times the typical average DPI choosen at 96x96.

The result is shown in the screenshots here https://bugs.mageia.org/attachment.cgi?id=8587. As you can see (the image is scaled for convenience) the icons of the Plasma's "System Settings" are almost unreadable, while instead the text scales proportionally.

Apparently plasma is able to scale everything proportionally to DPI without the need of extra tweaking, or playing with env var or xrdb entries, but in this case it fails. The problems seems in the line:

QT_AUTO_SCREEN_SCALE_FACTOR=0

of the script /usr/bin/startkde, which forces QT_AUTO_SCREEN_SCALE_FACTOR to 0, and thus "disables the automatic scaling based on the pixel density of the monitor for QT applications". IMHO this shouldn't be forced in the startup script, but should be left to system decide whether to apply or not, because if a user decide to force the QT_AUTO_SCREEN_SCALE_FACTOR=1 somewhere in startup scripts, those entries will be overridden by the startkde override.

Removing it, would fix the problem, and Plasma will have the right behaviour, i.e. scale the icons, the widgets and the text, proportionally when requested, as you can see here: https://bugs.mageia.org/attachment.cgi?id=8586, 

I attach the fix.
Comment 1 David Edmundson 2016-11-04 11:53:10 UTC
Thanks, but there's a reason it's like this. 

With it enabled *and* manual scaling set, which you've also left enabled, some apps (nextcloud for example) will double scale.
 
Also we have a huge problem that many many monitors report wrong DPI, if you leave auto on by default you get a tonne of bug reports. 

For that reason we have a manual setting in kscreen; that also adjusts your xrdb DPI which means GTK2 and Qt4 apps /sort of/ scale the font.
Comment 2 Giuseppe Ghibò 2016-11-04 12:57:39 UTC
The problem is that in this way you make it impossible to fix outside Plasma trough extra init scripts, unless one would change manually the binary of startkde, which usually nobody do because that would require altering the binary of a package in /usr/bin.

It's not that manual scaling I left enabled, but rather I prefer to let decide that outside Plasma, in other (x)init scripts.

Actually getting HiDPI working everywhere is almost impossible, as you fix something to get good looking and get other things wrong. Here the real problem is not the text size scaling, but the size of widgets (icons, scroll bars, etc.). Indirectly it affects also text scaling, but in spacing rather than sizing (you might see for instance fonts of right size, but wrong spaced vertically).

Furthermore adjusting xrdb trough fixing for instance Xft.dpi: value will led to unpredictable results to other applications (e.g. libreoffice, firefox), so from my experience the best results is achieved leaving global xrdb Xft.dpi settings untouched, and settings QT_AUTO_SCREEN_SCALE_FACTOR=1.

If you want to get the best of both the configuration I suggested, and yours, a good idea would be to keep the forcing the setting of the 
QT_AUTO_SCREEN_SCALE_FACTOR=0 outside startkde script (because that's mainly common to QT apps), in this way:

-export QT_AUTO_SCREEN_SCALE_FACTOR=0
+source /etc/sysconfig/plasmaqtsettings
+if [ -n "$QT_AUTO_SCREEN_SCALE_FACTOR" ]; then
+   export QT_AUTO_SCREEN_SCALE_FACTOR
+fi

and in /etc/sysconfig/plasmaqtsettings you place

QT_AUTO_SCREEN_SCALE_FACTOR=0

as default. The result for you is equivalent and it's not changing, QT_AUTO_SCREEN_SCALE_FACTOR=0 before, QT_SCREEN_SCALE_FACTOR=0 now, but
that /etc/sysconfig/plasmaqtsettings can be marked as a "config" file, so it can be altered either manually or by some extra config util, and won't change with package upgrades. At most a user can even decide to place in /etc/sysconfig/plasmaqtsettings

QT_AUTO_SCREEN_SCALE_FACTOR=1

there, and enable the autoscaling, as he prefer. You already did a similar mechanism in the same script for QT_SCREEN_SCALE_FACTORS.

Consider also that nowadays it's important the dynamic scaling with dpi. It's not that once you fixed the DPI that will stay to that dpi there forewer. One might have for instance have a "live installation", which one might boot with an HiDPI or not. So it's important to having something that scales automatically for *most* of the applications, without continuosly adjusting the icons size, fonts size, scale factor (of course there could be always some exception). Another use where dynamic setting is important is for instance when you might adjust the screen resolution (and thus dpi as consequence) in hardware and dynamically (e.g. you might have a 3820x2140 monitor but decide to have it working at 1920x1080 or 2560x1440).
Comment 3 Giuseppe Ghibò 2016-11-05 01:44:10 UTC
Created attachment 102041 [details]
patch equivalent to original behaviour of QT_AUTO_SCREEN_SCALE_FACTOR=0

This patch maintains the same original behaviour of QT_AUTO_SCREEN_SCALE_FACTOR=0 but moves the configuration in an external config file.
Comment 4 David Edmundson 2016-11-06 00:40:17 UTC
Plasma already has a system for allowing you to set env vars between that part of startkde and kdeinit launching.

Any autostart scripts set as pre-startup are sourced and env vars can be modified.
Comment 5 Giuseppe Ghibò 2016-11-06 15:18:53 UTC
Perfect.