Bug 480828 - kwin: poor experience with Gtk apps and 175% display scaling
Summary: kwin: poor experience with Gtk apps and 175% display scaling
Status: RESOLVED INTENTIONAL
Alias: None
Product: systemsettings
Classification: Applications
Component: kcm_style (show other bugs)
Version: 6.0.1
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Plasma Bugs List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-02-04 05:34 UTC by Vasily Khoruzhick
Modified: 2025-01-15 20:40 UTC (History)
3 users (show)

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


Attachments
kwin_175percent_scaling_1_dpi_172032.png (91.71 KB, image/png)
2024-02-04 05:34 UTC, Vasily Khoruzhick
Details
kwin_175percent_scaling_2_dpi_86016.png (108.32 KB, image/png)
2024-02-04 05:35 UTC, Vasily Khoruzhick
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Vasily Khoruzhick 2024-02-04 05:34:39 UTC
Created attachment 165522 [details]
kwin_175percent_scaling_1_dpi_172032.png

SUMMARY

When display scaling is set to 175%, kwin communicates scaling factor of 1 to Gtk apps and sets Gdk/UnscaledDPI in xsettingsd config to 172032. That results in properly sized text, but small widgets, as a result text doesn't fit into buttons, menus, dropdown selections, etc.

It works much better I force scaling factor to 2 and set Gdk/UnscaledDpi to 86016

I believe that kwin should properly round fractional scaling factors instead of flooring it.

See attached screenshots as example.


STEPS TO REPRODUCE
1. Set display scaling to 175%
2. Open any Gtk3 app (e.g. Orca Slicer)

OBSERVED RESULT

Text doesn't fit widgets, since text is scaled, but widgets are not

EXPECTED RESULT

Text should fit widgets

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: Archlinux, plasma 5.27.10
(available in About System)
KDE Plasma Version: 5.27.10
KDE Frameworks Version: 5.114.0
Qt Version: 5.15.12
Comment 1 Vasily Khoruzhick 2024-02-04 05:35:05 UTC
Created attachment 165523 [details]
kwin_175percent_scaling_2_dpi_86016.png
Comment 2 Vlad Zahorodnii 2024-02-06 12:10:55 UTC
kwin doesn't really set the dpi and it ceils the scale factor for apps that don't support fractional scaling, I believe kde-gtk-config does it. Is this an xwayland or a wayland app?
Comment 3 Vasily Khoruzhick 2024-02-06 23:56:25 UTC
(In reply to Vlad Zahorodnii from comment #2)
> kwin doesn't really set the dpi and it ceils the scale factor for apps that
> don't support fractional scaling, I believe kde-gtk-config does it. Is this
> an xwayland or a wayland app?

I checked Orca Slicer sources and looks like it forces X11 backend for GTK due to some issue with WxGTK:

https://github.com/SoftFever/OrcaSlicer/blob/8b1b3355e6ebf97475474661dc0516663a85798c/src/OrcaSlicer.cpp#L890

So apparently the issue is with kde-gtk-config, for some reason it sets Gdk/WindowScalingFactor to 1 if display scaling is 175%. Let me move the bug to kde-gtk-config package
Comment 4 Vasily Khoruzhick 2024-02-07 00:11:23 UTC
Hm, I can't find kde-gtk-config product. Any suggestions where it should be reported?

It looks like kde-gtk-config floors scaling factor:

https://github.com/KDE/kde-gtk-config/blob/master/kded/gtkconfig.cpp#L254
Comment 5 Vasily Khoruzhick 2024-02-07 00:27:40 UTC
BTW, Prusa Slicer also forces X11 GDK backend, you can try flatpak with it to reproduce the issue. Once display scaling is set to 175%, Prusa Slicer UI is more cramped and icons are barely distinguishable.
Comment 6 Nate Graham 2024-02-07 00:43:44 UTC
Hmm, floor() is probably not appropriate here. It should at least round(), not floor(). But maybe we can also find some way to approximate a fractional scale factor even though GTK apps don't officially support this.
Comment 7 Bug Janitor Service 2024-02-17 00:30:25 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kde-gtk-config/-/merge_requests/104
Comment 8 Nate Graham 2024-02-20 20:39:50 UTC
Git commit 28b724674815ecb23c078a0d23e33ab64d0df69a by Nate Graham, on behalf of Vasily Khoruzhick.
Committed on 20/02/2024 at 20:39.
Pushed by ngraham into branch 'master'.

Round x11GlobalScaleFactor instead of flooring it

When display scaling is set to 175%, flooring scale factor down to 1
results in very cramped widgets. To the point when the text scaled by
1.75 doesn't fit the widgets.

Properly round x11GlobalScaleFactor to avoid that.

Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
Fixed-IN: 6.0

M  +7    -2    kded/gtkconfig.cpp

https://invent.kde.org/plasma/kde-gtk-config/-/commit/28b724674815ecb23c078a0d23e33ab64d0df69a
Comment 9 Nate Graham 2024-02-20 20:54:00 UTC
Git commit fab18c5b7c5fb1648aa027af031a8bf5fd090be0 by Nate Graham, on behalf of Vasily Khoruzhick.
Committed on 20/02/2024 at 20:41.
Pushed by ngraham into branch 'Plasma/6.0'.

Round x11GlobalScaleFactor instead of flooring it

When display scaling is set to 175%, flooring scale factor down to 1
results in very cramped widgets. To the point when the text scaled by
1.75 doesn't fit the widgets.

Properly round x11GlobalScaleFactor to avoid that.

Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
Fixed-IN: 6.0


(cherry picked from commit 28b724674815ecb23c078a0d23e33ab64d0df69a)

M  +7    -2    kded/gtkconfig.cpp

https://invent.kde.org/plasma/kde-gtk-config/-/commit/fab18c5b7c5fb1648aa027af031a8bf5fd090be0
Comment 10 Nate Graham 2024-02-20 20:54:04 UTC
Git commit 6b3865a72baff3932fbe89ef0c44ff1b9bb4cd10 by Nate Graham, on behalf of Vasily Khoruzhick.
Committed on 20/02/2024 at 20:41.
Pushed by ngraham into branch 'Plasma/5.27'.

Round x11GlobalScaleFactor instead of flooring it

When display scaling is set to 175%, flooring scale factor down to 1
results in very cramped widgets. To the point when the text scaled by
1.75 doesn't fit the widgets.

Properly round x11GlobalScaleFactor to avoid that.

Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
Fixed-IN: 6.0


(cherry picked from commit 28b724674815ecb23c078a0d23e33ab64d0df69a)

M  +7    -2    kded/gtkconfig.cpp

https://invent.kde.org/plasma/kde-gtk-config/-/commit/6b3865a72baff3932fbe89ef0c44ff1b9bb4cd10
Comment 11 Vasily Khoruzhick 2024-03-08 05:51:39 UTC
Reopening, since MR was reverted
Comment 12 Vasily Khoruzhick 2024-04-03 17:36:29 UTC
Any suggestions on how to proceed with the bug?

MR got reverted because it breaks JB IDE that interprets GTK settings different from GTK, so basically the choice is either GTK apps look good at 175% or JB IDE looks good at 175%.
Comment 14 Nate Graham 2024-04-04 21:52:36 UTC
My inclination would be to push the more correct fix and let JetBrains fix their own bug.
Comment 15 Vasily Khoruzhick 2024-04-08 18:37:23 UTC
(In reply to Nate Graham from comment #14)
> more correct fix

Could you please elaborate on what it would be?
Comment 16 Nate Graham 2024-04-08 18:43:51 UTC
The one that was merged and then reverted after we found out that JetBrains IDEs are doing something odd.
Comment 17 Vasily Khoruzhick 2024-11-27 20:19:32 UTC
(In reply to Nate Graham from comment #16)
> The one that was merged and then reverted after we found out that JetBrains
> IDEs are doing something odd.

So it's been 7 months, I don't see any activity in JetBrains IDE ticket [1] and I don't think that they have any interest in fixing it as long as the change was reverted. Is it time to fix it for GTK and let JetBrains fix it on their side?

[1] https://youtrack.jetbrains.com/issue/IJPL-43538/Make-IDE-based-scaling-behave-more-like-GTK
Comment 18 Nate Graham 2024-12-10 20:57:49 UTC
Testing today's git master with PrusaSlicer, it looks fine to me at 175% scale, both text and widget sizing.

Are there any other apps that exhibit issues I could test with?
Comment 19 Vasily Khoruzhick 2024-12-23 00:48:56 UTC
(In reply to Nate Graham from comment #18)
> Testing today's git master with PrusaSlicer, it looks fine to me at 175%
> scale, both text and widget sizing.
> 
> Are there any other apps that exhibit issues I could test with?

I still see the issue with Prusa Slicer-2.8.1 and Orca Slicer 2.2.0
Comment 20 Nate Graham 2025-01-02 18:57:35 UTC
I can't reproduce the issue with those apps and 175% scaling on git master.
Comment 21 Vasily Khoruzhick 2025-01-12 00:58:40 UTC
I'm still seeing the issue with 6.2.5. What commit in git master is supposed to fix the issue?
Comment 22 Nate Graham 2025-01-13 16:50:13 UTC
I don't know.
Comment 23 David Edmundson 2025-01-15 15:57:48 UTC
There is nothing else we can do here. 

It is known that some apps cannot scale themselves when the font DPI is bumped, please change the Display Configuration setting "Legacy applications (X11) - scaled by system"  that will keep the font DPI at 96.
Comment 24 Vasily Khoruzhick 2025-01-15 20:40:25 UTC
(In reply to David Edmundson from comment #23)
> There is nothing else we can do here. 

Please see https://invent.kde.org/plasma/kde-gtk-config/-/merge_requests/104

It was reverted though beacase a non-GTK app interprets GTK settings differently.

> It is known that some apps cannot scale themselves when the font DPI is
> bumped, please change the Display Configuration setting "Legacy applications
> (X11) - scaled by system"  that will keep the font DPI at 96.

It's not really a solution, but if you need to close the bug just for the sake of closing the bug, sure.