Bug 466463 - Different scaling on HiDpi display for applications in 5.27.1
Summary: Different scaling on HiDpi display for applications in 5.27.1
Status: RESOLVED FIXED
Alias: None
Product: plasmashell
Classification: Plasma
Component: Startup process (show other bugs)
Version: 5.27.1
Platform: Other Linux
: NOR normal
Target Milestone: 1.0
Assignee: Plasma Bugs List
URL:
Keywords: regression
: 466506 467386 (view as bug list)
Depends on:
Blocks:
 
Reported: 2023-02-26 09:43 UTC by Michal Hlavac
Modified: 2023-04-11 07:36 UTC (History)
10 users (show)

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


Attachments
Different scale for some applications (2.19 MB, image/png)
2023-02-26 09:43 UTC, Michal Hlavac
Details
dpi issue (434.95 KB, image/png)
2023-02-28 07:07 UTC, painless roaster
Details
Messed up desktop on Wayland (2.00 MB, image/png)
2023-03-04 22:53 UTC, Parag W
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michal Hlavac 2023-02-26 09:43:44 UTC
Created attachment 156754 [details]
Different scale for some applications

SUMMARY
***
Using OpenSUSE Tumbleweed X11 with plasma 5.27.1 and fonts for QT applications has different dpi, e.g. menu has correct dpi, but kmail, or ksettings has wrong dpi. Also for GTK applications I must use GDK_SCALE=2 to scale correctly. 

In wayland scaling unified, but also wrong. It looks like it uses dpi 96, so everything is small.
***


STEPS TO REPRODUCE
1. Login to plasma using 4K monitor.
2. Try some applications
3. 

OBSERVED RESULT

see screenshot


EXPECTED RESULT

Unified scaling.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: openSUSE Tumbleweed (20230224)
(available in About System)
KDE Plasma Version: 5.27.1
KDE Frameworks Version: 5.103.0
Qt Version: 5.15.8+kde160

ADDITIONAL INFORMATION

Screenshot in attachment.
Comment 1 painless roaster 2023-02-27 17:53:36 UTC
The same problem is on Fedora 36 and 37 with Plasma 5.27.1. Changing DPI affects the desktop and main menu, but all applications remain running at dpi 96.
Comment 2 Unknown 2023-02-27 19:25:08 UTC
Fedora Linux 36 with Plasma 5.27.1 here, and this seems to be the issue I'm experiencing...

Everything is stuck at 96 DPI, and looks tiny on QHD at 27in. Global scale makes everything blurry, while forcing font DPI does nothing... except when xsettingsd randomly decides not to run on startup, turning the desktop into a mess. See also https://bugs.kde.org/show_bug.cgi?id=426788#c14
Comment 3 Luca Bacci 2023-02-27 20:30:10 UTC
Hi everyone, thanks for the bug report! I'm going to open an MR to address this issue. If everything goes smoothly the fix will be available for KDE 5.27.3

Best,
Luca
Comment 4 Michal Hlavac 2023-02-27 20:49:26 UTC
Thanks Luca, would be really great to have it in 5.27.2, anyway maybe a kind of workaround for GTK3+ & java applications is to run: 

GDK_SCALE=2 program

or echo "GDK_SCALE=2" >> ~/.profile 

this basically saves my work life.
Comment 5 painless roaster 2023-02-28 06:52:18 UTC
(In reply to Luca Bacci from comment #3)
> Hi everyone, thanks for the bug report! I'm going to open an MR to address
> this issue. If everything goes smoothly the fix will be available for KDE
> 5.27.3
> 
> Best,
> Luca

Thank you for your helpful attitude. Please could this problem be resolved urgently and a patch published. The bug is blocking all users who have a high-dpi monitor.
Comment 6 painless roaster 2023-02-28 07:07:55 UTC
Created attachment 156821 [details]
dpi issue

I have attached a picture describing the problem.
Comment 7 nyanpasu64 2023-02-28 08:04:55 UTC
I noticed that restarting kwin_x11 set the title bar DPI from override 120 to default 96, and running `killall kded5` caused my override DPI to apply again.

I think that every time I restart plasma-kded.service, there's a random chance that 120 DPI applies (instantly to Firefox and Armcord), Armcord's font size grows and shrinks quickly, or nothing at all happens (remains at 96 DPI). Is there a race condition somewhere in kded5's code?
Comment 8 Bug Janitor Service 2023-02-28 10:59:59 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kde-gtk-config/-/merge_requests/64
Comment 9 painless roaster 2023-02-28 11:26:10 UTC
(In reply to Bug Janitor Service from comment #8)
> A possibly relevant merge request was started @
> https://invent.kde.org/plasma/kde-gtk-config/-/merge_requests/64

It's not just a problem with gtk applications. DPI is not accepted even by native kde apps.
Comment 10 painless roaster 2023-02-28 11:27:47 UTC
(In reply to nyanpasu64 from comment #7)
> I noticed that restarting kwin_x11 set the title bar DPI from override 120
> to default 96, and running `killall kded5` caused my override DPI to apply
> again.
> 
> I think that every time I restart plasma-kded.service, there's a random
> chance that 120 DPI applies (instantly to Firefox and Armcord), Armcord's
> font size grows and shrinks quickly, or nothing at all happens (remains at
> 96 DPI). Is there a race condition somewhere in kded5's code?

I confirm that killing the kded5 task temporarily solves the problem.
Comment 11 Luca Bacci 2023-02-28 11:36:36 UTC
(In reply to painless roaster from comment #9) 
> It's not just a problem with gtk applications. DPI is not accepted even by
> native kde apps.

Currently kde-gtk-config sets the xft/DPI XSetting which is read both by GTK and Qt applications, hence why the problem appears even outside of GTK applications
Comment 12 painless roaster 2023-02-28 11:38:22 UTC
(In reply to Bug Janitor Service from comment #8)
> A possibly relevant merge request was started @
> https://invent.kde.org/plasma/kde-gtk-config/-/merge_requests/64

Well, that's really unexpected. On fedora, removing the kde-gtk-config package solves the problem of native kde applications. So it is indeed possible that the patch will help.
Comment 13 nyanpasu64 2023-02-28 11:39:33 UTC
Not sure what's going on... Is the "xft/DPI XSetting" the variable seen by `xrdb -query -all`? Observations:

- `xrdb -query -all|grep Xft|sort` shows `Xft.dpi:        120` even with windows erroneously at 96dpi.
- Running xsettingsd (not sure what it does) fixes DPI, even after Ctrl-C. Running again reverts to 96 DPI, but Ctrl-C reapplies font DPI.
Comment 14 painless roaster 2023-02-28 17:19:25 UTC
(In reply to nyanpasu64 from comment #13)
> Not sure what's going on... Is the "xft/DPI XSetting" the variable seen by
> `xrdb -query -all`? Observations:
> 
> - `xrdb -query -all|grep Xft|sort` shows `Xft.dpi:        120` even with
> windows erroneously at 96dpi.
> - Running xsettingsd (not sure what it does) fixes DPI, even after Ctrl-C.
> Running again reverts to 96 DPI, but Ctrl-C reapplies font DPI.

That's a good point about xsettingsd. If the whole xsettingsd package is uninstalled, everything goes without a problem. :-)
Comment 15 painless roaster 2023-02-28 17:20:46 UTC
(In reply to Bug Janitor Service from comment #8)
> A possibly relevant merge request was started @
> https://invent.kde.org/plasma/kde-gtk-config/-/merge_requests/64

I tried the patch and it didn't help.
So far, uninstalling xsettingsd works best.
Comment 16 Nate Graham 2023-03-01 15:47:47 UTC
*** Bug 466506 has been marked as a duplicate of this bug. ***
Comment 17 painless roaster 2023-03-02 06:34:41 UTC
Version 5.27.2 did not solve the problem. :-(
Comment 18 Michael Hamilton 2023-03-02 06:55:43 UTC
(In reply to Michal Hlavac from comment #4)
> Thanks Luca, would be really great to have it in 5.27.2, anyway maybe a kind
> of workaround for GTK3+ & java applications is to run: 
> 
> GDK_SCALE=2 program
> 
> or echo "GDK_SCALE=2" >> ~/.profile 
> 
> this basically saves my work life.

The easiest workaround is to use settings->Startup and Shutdown->Background Services and disable GNOME/GTK Settings Synchronisation Service - fixes KDE and other app's (as noted in https://bugs.kde.org/show_bug.cgi?id=466506).
Comment 19 Michael Hamilton 2023-03-04 06:33:59 UTC
(In reply to Nate Graham from comment #16)
> *** Bug 466506 has been marked as a duplicate of this bug. ***

In answer to the question from Bug 466506: 
> Can you try again with Plasma 5.27.2? We removed some unnecessary font size handling stuff in that bugfix release.

Tumbleweed updated to 5.27.2 didn't help, it's the same as I described in Bug 466506.  

Disabling the GNOME/GTK Settings Synchronisations Service remains an easy workaround.
Comment 20 Luca Bacci 2023-03-04 10:06:03 UTC
Hi painless.roaster! Could you try again with https://invent.kde.org/plasma/kde-gtk-config/-/merge_requests/63? It's now finished and should work as is.

Thanks!
Comment 21 Parag W 2023-03-04 22:53:49 UTC
Created attachment 157004 [details]
Messed up desktop on Wayland

This looks like the same issue - hopefully will be addressed in .3 release - Plasma Wayland is unusable on 5.27.x - OpenSuSE Tumbleweed, 4k monitor, scaling set to 200%. Not just for GTK apps - the whole desktop and all KDE apps have wrong scale.

Works fine if I switch to X11 so seems to be Wayland specific.
Comment 22 painless roaster 2023-03-05 11:02:15 UTC
(In reply to Luca Bacci from comment #20)
> Hi painless.roaster! Could you try again with
> https://invent.kde.org/plasma/kde-gtk-config/-/merge_requests/63? It's now
> finished and should work as is.
> 
> Thanks!

I've tried the fix to build the kde-gtk-config package in Fedora 36 and 37. This solved the problem for both of them. Good work. Thank you!
Comment 23 Parag W 2023-03-05 16:43:12 UTC
#63 Fixes the problem for me as well.
Comment 24 Nate Graham 2023-03-15 20:18:48 UTC
*** Bug 467386 has been marked as a duplicate of this bug. ***
Comment 25 Fushan Wen 2023-03-17 16:51:35 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 461106
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 26 Fushan Wen 2023-03-17 18:05:53 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 461106
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
Comment 27 Michal Hlavac 2023-04-10 17:52:44 UTC
After upgrading to framework 5.105 all GTK application runs with dpi 96.
Plasma: 5.27.4
Framework: 5.105
Qt: 5.15.8
Kernel: 6.2.9
Comment 28 Luca Bacci 2023-04-10 19:57:15 UTC
Hello, Michal! Is it on a Wayland session or X11 session? Can you post the output of:

dump_xsettings
ps aux | grep -iE 'xsettings|kded'

Also, what scaling settings do you have in System Settings > Display and Monitor

Thank you,
Luca
Comment 29 Michal Hlavac 2023-04-10 20:35:28 UTC
Hi Luca, I run primary on X11. But I tried Wayland and there it looks like all Plasma and also GTK applications runs with DPI 96.

================================================================================

X11 output:

hlavki@hlknb:~> dump_xsettings
Gdk/UnscaledDPI 98304
Gdk/WindowScalingFactor 1
Gtk/ButtonImages 1
Gtk/CursorThemeName "breeze_cursors"
Gtk/CursorThemeSize 36
Gtk/DecorationLayout "icon:minimize,maximize,close"
Gtk/EnableAnimations 1
Gtk/FontName "Noto Sans,  8"
Gtk/MenuImages 1
Gtk/PrimaryButtonWarpsSlider 0
Gtk/ToolbarStyle 3
Net/IconThemeName "Papirus"
Net/ThemeName "Breeze"

hlavki@hlknb:~> ps aux | grep -iE 'xsettings|kded'
hlavki   22696  1.3  0.4 2202624 154352 ?      Ssl  22:22   0:01 /usr/bin/kded5
hlavki   22794  0.0  0.0   7656  4480 ?        S    22:22   0:00 /usr/bin/xsettingsd
hlavki   25977  0.0  0.0   6528  2304 pts/1    S+   22:24   0:00 grep --color=auto -iE xsettings|kded

Global Scale: 100%

================================================================================

Wayland output:

Gdk/UnscaledDPI 98304
Gdk/WindowScalingFactor 1
Gtk/ButtonImages 1
Gtk/CursorThemeName "breeze_cursors"
Gtk/CursorThemeSize 36
Gtk/DecorationLayout "icon:minimize,maximize,close"
Gtk/EnableAnimations 1
Gtk/FontName "Noto Sans,  8"
Gtk/MenuImages 1
Gtk/PrimaryButtonWarpsSlider 0
Gtk/ToolbarStyle 3
Net/IconThemeName "Papirus"
Net/ThemeName "Breeze"

hlavki   26573  0.8  0.4 2273276 149968 ?      Ssl  22:25   0:00 /usr/bin/kded5
hlavki   26627  0.0  0.0   7668  4224 ?        S    22:25   0:00 /usr/bin/xsettingsd
hlavki   28704  0.0  0.0   6528  2304 pts/2    S+   22:27   0:00 grep --color=auto -iE xsettings|kded

Global Scale: 100%
Comment 30 Luca Bacci 2023-04-10 20:42:16 UTC
Ok, things look good there. Can you also have a look in System Settings > Appearance > Fonts > Force Font DPI. Is that set to 96 DPI or some other value?

Luca
Comment 31 Michal Hlavac 2023-04-10 20:48:26 UTC
Force DPI is off.
https://paste.opensuse.org/pastes/462da4efefda
Comment 32 Luca Bacci 2023-04-10 20:52:18 UTC
Alright! May I ask how did you set the DPI value for Qt / Plasma applications?
Comment 33 Michal Hlavac 2023-04-11 07:36:51 UTC
Sorry, the cause of my problem was file ~/.Xresources with Xft.dpi:   192

When I removed it, it works as expected. thanks