| Summary: | GTK3 does not follow HiDPI scaling by default -- and quick fix | ||
|---|---|---|---|
| Product: | [Plasma] plasmashell | Reporter: | battaglia01 |
| Component: | general | Assignee: | David Edmundson <kde> |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | CC: | alexkde, bugseforuns, ivan, mosra, plasma-bugs-null, postix |
| Priority: | NOR | ||
| Version First Reported In: | 5.12.3 | ||
| Target Milestone: | 1.0 | ||
| Platform: | Other | ||
| OS: | Linux | ||
| Latest Commit: | Version Fixed/Implemented In: | ||
| Sentry Crash Report: | |||
| Attachments: |
Incorrect default scaling behavior for GTK3 apps - ex: manjaro-hello and Lollypop
Correct GTK3 scaling behavior - GDK_SCALE=2 and GDK_DPI_SCALE=0.5 |
||
Created attachment 111624 [details]
Correct GTK3 scaling behavior - GDK_SCALE=2 and GDK_DPI_SCALE=0.5
I split this off from bug 391682 because that there were multiple causes for the different HiDPI problems mentioned. Most of the problems turned out to be about Qt scaling, and so the bug was marked as a duplicate of bug 356446. This is totally separate from that and so I've made a new report for it, as I didn't see it elsewhere. See 387849 which resulted in aba3d48c07fce03d9e23717fc24de06aad5c75d7 and the revert: 389523 If you can come up with a quick fix that won't create the problems mentioned in 389523, that would be great. Thanks - I'll add my notes there. In short, I get the same problems here with fractional scaling. It seems to be messy. Actually, since that bug is listed as "fixed," it's probably better if I put my notes here. Here's what I've found: 1. I get the same problem with fractional scaling for Chrome, Firefox, Thunderbird, if I set Kwin's scaling to 1.9, GDK_SCALE=1.9, and GDK_DPI_SCALE to 0.526 (= 1/1.9). 2. Unsetting GDK_SCALE and GDK_DPI_SCALE fixes the problems in those cases, but leaves other GTK3 apps scaled incorrectly. As usual, fractional scaling ruins all sorts of things. But, whatever the solution is, it is *not* to put fractional scaling values in GDK_SCALE. If that environment variable is set at all, it must be an integer, as per the GTK-X11 documentation: https://developer.gnome.org/gtk3/stable/gtk-x11.html So we have the strange situation where if we leave GDK_SCALE and GDK_DPI_SCALE unset, Chrome/Firefox/Thunderbird somehow magically know how to follow KDE's setting and scale properly, but other GTK3 apps do not. If we set those environment variables in any way, then that fixes the other GTK3 apps, and ruins Chrome/Firefox/Thunderbird. You can't even really fix this by just rounding GDK_SCALE, and setting GDK_DPI_SCALE to its inverse. This would fix the other GTK3 apps, but would make things messy for Chrome/Firefox/Thunderbird, which would then have a different rounded scaling value applied than the smooth, correct fractional scaling they would give you by default. Some of the issues with GDK_SCALE appear to be upstream with the various browsers, which may be getting their DPI info from somewhere else to support fractional scaling. I think the easy band-aid fix is to have KDE auto-set the GDK_SCALE and GDK_DPI_SCALE env's **only if** the scaling value is set to an integer. In other words, if I set scale=2.0, it sets these variables to GDK_SCALE=2 and GDK_DPI_SCALE=0.5. On the other hand, if I set them to scale=1.5, it leaves them unset. This may be a good approach for fractional scaling issues in general. |
Created attachment 111623 [details] Incorrect default scaling behavior for GTK3 apps - ex: manjaro-hello and Lollypop In GTK3 apps, the DPI scaling option picked in KDE's system display settings is dropped erroneously for GTK3. The attached pictures demonstrate the behavior, as well as the behavior when changing the environment variables. In the first attached picture, I have KDE's scale variable set at 2.0. You can see that none of the widgets, window decorations, etc are not scaled and that everything is tiny. In the second attached picture, I set the environment variables GDK_SCALE=2 and GDK_DPI_SCALE=0.5. You can see that the scaling now works properly. Setting GDK_SCALE=2 scales all of the components, but also double-scales the fonts, so that they end up being scaled 4x. Setting GDK_DPI_SCALE=0.5 then "un-scales" the fonts, so that they end up being scaled only 2x. I'm not sure if this is the best fix, but at least it shows it's possible to get the right GTK scaling working in Plasma. I've seen this behavior on both Plasma 5.11 and 5.12.