Bug 461106 - Xft.dpi should not be overridden when XWayland applications are configured to scale by themselves and forceFontDPIWayland is not set
Summary: Xft.dpi should not be overridden when XWayland applications are configured to...
Status: RESOLVED FIXED
Alias: None
Product: plasmashell
Classification: Plasma
Component: Startup process (show other bugs)
Version: 5.26.0
Platform: Arch Linux Linux
: NOR minor
Target Milestone: 1.0
Assignee: Nate Graham
URL:
Keywords: wayland
Depends on:
Blocks:
 
Reported: 2022-10-28 10:06 UTC by einbert-xeride
Modified: 2023-03-17 18:05 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.27.4


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description einbert-xeride 2022-10-28 10:06:32 UTC
SUMMARY

plasma-workspace will override Xft.dpi settings for XWayland applications according to the DPI setting. The DPI setting is picked from kcmfonts "forceFontDPIWayland" entry in Wayland sessions, and defaults to 96 when it's not set. When Xft.dpi is 96 and "Apply scaling themselves", XWayland applications (in my case, Jetbrains IDEs and Discord) may scale at 1x instead of manually specified scaling factor indicated by Xft.dpi in ~/.Xresources (in my case, 192, which is 2x scaling). Manually setting Xft.dpi to 192 would make these applications use 2x scaling, but that will not survive a reboot.

Switching to "Scaled by the system" is not an option because that would be too blurry under 2x scaling.

Editing VM options for Jetbrains IDEs / Manually setting command line flags for Discord would be an option, but that is too specific. I want a generic solution that works for all UI toolkits that don't support Wayland, but honor Xft.dpi and perform scaling accordingly.

Code comment (plasma-workspace,b2b507070,kcms/krdb/krdb.cpp:409) indicates that setting Xft.dpi to 96 due to "we have wayland scaling on top", which is not true when XWayland applications are configured to scale by themselves. So I guess it would be better if we keep Xft.dpi as-is in Wayland session when XWayland applications scale by themselves, or at least update the code comment indicating that 96 dpi is enfoced regardless of the XWayland scaling option.

STEPS TO REPRODUCE
1. Start a plasma wayland session.
2. Setting `Display Configutation - Scale` to 200%, `Display Configuration - Legacy Applications (X11)` to `Apply scaling themselves`. Uncheck `Fonts - Force font DPI`.
3. Start any Jetbrains IDE, or Discord.

OBSERVED RESULT

4. Noticing that they are not scaled.

EXPECTED RESULT

5. xrdb -merge a file containing "Xft.dpi: 192".
6. Restart any Jetbrains IDE or Discord.
7. Noticing that they're scaling at 2x.

SOFTWARE/OS VERSIONS
Windows: N/A
macOS: N/A
Linux/KDE Plasma: Arch Linux (last sync at 2022-10-28T13:05:16+0800), KDE Plasma 5.26.2
(available in About System)
KDE Plasma Version: 5.26.2
KDE Frameworks Version: 5.99.0
Qt Version: 5.15.6

ADDITIONAL INFORMATION
Jetbrains IDE used in the test is Intellij IDEA Ultimate 2022.2.3, downloaded from Jetbrains Toolbox.
Discord used in the test is 0.0.21, packed by Arch Linux contributors.
Only one monitor is attached: DELL U2720Q. No built-in display.
Comment 1 Bug Janitor Service 2022-11-04 04:21:59 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/2299
Comment 2 Nate Graham 2023-03-08 15:07:59 UTC
Luca, is this fixed now?
Comment 3 Luca Bacci 2023-03-08 15:36:34 UTC
Hi Nate! Yes, should be fixed by https://invent.kde.org/plasma/kde-gtk-config/-/merge_requests/63. Would be great to get it in for KDE 5.27.3 ;)
Comment 4 Nate Graham 2023-03-08 15:47:54 UTC
Cool, will review today. Thanks a lot for your work on this stuff! It's much appreciated.
Comment 5 Fushan Wen 2023-03-17 16:51:43 UTC
Git commit 1b66b4b5fd6ccc8b5b938fcaaed78639360dfc47 by Fushan Wen, on behalf of Luca Bacci.
Committed on 17/03/2023 at 16:51.
Pushed by fusionfuture into branch 'master'.

Beside monitor scaling factors, a user may specify a preferred
text DPI size from the system configuration utility (KCM fonts)
That setting is stored inside the kcmfonts configuration file;
one entry is kept for Plasma/X11 sessions, "forceFontDPI", and
another for Plasma/Wayland sessions, "forceFontDPIWayland".

Here we make kde-gtk-config read such entries (depending on the
Plasma session type) and then set the GTK text scaling settings
accordingly.

Fixes #3
Related: bug 466463
FIXED-IN: 5.27.4

M  +2    -0    kded/config_editor/gsettings.cpp
M  +9    -1    kded/config_editor/xsettings.cpp
M  +1    -0    kded/config_editor/xsettings.h
M  +23   -0    kded/configvalueprovider.cpp
M  +5    -0    kded/configvalueprovider.h
M  +37   -12   kded/gtkconfig.cpp
M  +2    -0    kded/gtkconfig.h

https://invent.kde.org/plasma/kde-gtk-config/commit/1b66b4b5fd6ccc8b5b938fcaaed78639360dfc47
Comment 6 Fushan Wen 2023-03-17 18:05:45 UTC
Git commit d2a84a92ca563b94fdfbea9d8edb8eb5955bccf0 by Fushan Wen, on behalf of Luca Bacci.
Committed on 17/03/2023 at 17:04.
Pushed by fusionfuture into branch 'Plasma/5.27'.

Beside monitor scaling factors, a user may specify a preferred
text DPI size from the system configuration utility (KCM fonts)
That setting is stored inside the kcmfonts configuration file;
one entry is kept for Plasma/X11 sessions, "forceFontDPI", and
another for Plasma/Wayland sessions, "forceFontDPIWayland".

Here we make kde-gtk-config read such entries (depending on the
Plasma session type) and then set the GTK text scaling settings
accordingly.

Fixes #3
Related: bug 466463
FIXED-IN: 5.27.4


(cherry picked from commit 1b66b4b5fd6ccc8b5b938fcaaed78639360dfc47)

M  +2    -0    kded/config_editor/gsettings.cpp
M  +9    -1    kded/config_editor/xsettings.cpp
M  +1    -0    kded/config_editor/xsettings.h
M  +23   -0    kded/configvalueprovider.cpp
M  +5    -0    kded/configvalueprovider.h
M  +37   -12   kded/gtkconfig.cpp
M  +2    -0    kded/gtkconfig.h

https://invent.kde.org/plasma/kde-gtk-config/commit/d2a84a92ca563b94fdfbea9d8edb8eb5955bccf0