Bug 443215 - GDK_SCALE and GDK_DPI_SCALE are hard coded and overwrite user config
Summary: GDK_SCALE and GDK_DPI_SCALE are hard coded and overwrite user config
Status: RESOLVED FIXED
Alias: None
Product: plasmashell
Classification: Plasma
Component: Startup process (show other bugs)
Version: master
Platform: Arch Linux Linux
: NOR wishlist
Target Milestone: 1.0
Assignee: Nate Graham
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-10-02 05:38 UTC by Liu Zhe
Modified: 2023-02-18 09:51 UTC (History)
11 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.27.1


Attachments
gtk unusable with wayland (169.81 KB, image/png)
2022-02-14 14:32 UTC, Sebastian Turzański
Details
gtk app unusable with wayland (194.14 KB, image/png)
2022-02-14 14:33 UTC, Sebastian Turzański
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Liu Zhe 2021-10-02 05:38:23 UTC
SUMMARY

In plasma wayland, GDK_SCALE and GDK_DPI_SCALE cannot be configured with ".pam_environment", ".profile", ".config/plasma-workspace/env", etc.

The variables are set to 1 in startplasma-wayland, seemingly after loading user config.

Code is here:

https://invent.kde.org/plasma/plasma-workspace/-/blob/e6cab5d96f7b51a5cf4be3d93a7e2d4fee1cddae/startkde/startplasma-wayland.cpp#L67

STEPS TO REPRODUCE
1. Write `export GDK_SCALE=2` to `.profile` and `.config/plasma-workspace/env/dpi.sh`.
2. Reboot.
3. Run printenv.

OBSERVED RESULT
`GDK_SCALE` is 1.

EXPECTED RESULT
`GDK_SCALE` is expected to be 2.

SOFTWARE/OS VERSIONS
plasma-workspace 5.22.5, packaged by Arch Linux.

ADDITIONAL INFORMATION
I edited startplasma-wayland bin file, changed string `GDK_SCALE` to `XXX_SCALE`. Now `GDK_SCALE` can be configured with `.pam_environment` as expected.
Comment 1 David Edmundson 2021-10-03 19:39:55 UTC
They are hardcoded to fix a bug.

On wayland scaling is set via the wayland protocol and there is no need for this.
Comment 2 Liu Zhe 2021-10-03 21:06:54 UTC
(In reply to David Edmundson from comment #1)
> They are hardcoded to fix a bug.
> 
> On wayland scaling is set via the wayland protocol and there is no need for
> this.

Frankly speaking wayland scaling is unusably blur. And for small factor like 125% it's way better to scale font only, which is not supported by wayland protocol to my knowledge.

I understand the bug it fixes but I believe a properly scaled browser is also a must-have feature.

Can we make this behavior configurable? Via system settings or... dirty workaround like PLASMA_GDK_DPI_SCALE.
Comment 3 notz76 2021-10-12 06:22:00 UTC
I have the same problem. KDE wayland display scaling (i need 110%-120%) is unusable because of heavy blurring.

QT apps are working ok with increasing the font, but GTK apps are too small because of GDK_SCALE set to 1.

I think we are not the only users, because all full hd screens on 13"/14" laptops need a small display scaling.
Comment 4 Yao Nianqing 2022-02-13 13:07:29 UTC
(In reply to David Edmundson from comment #1)
> They are hardcoded to fix a bug.
> 
> On wayland scaling is set via the wayland protocol and there is no need for
> this.

Actually, hard-coding GDK_DPI_SCALE will make GTK applications not scaled when using DPI settings of "Font" KCM. 

Under this case, QT applications will scale normally, while GTK applications won't. So Firefox is affected by this, and an improperly scaled browser should considered a bug too.
Comment 5 Sebastian Turzański 2022-02-14 14:32:19 UTC
Created attachment 146713 [details]
gtk unusable with wayland
Comment 6 Sebastian Turzański 2022-02-14 14:33:10 UTC
Created attachment 146714 [details]
gtk app unusable with wayland
Comment 7 Sebastian Turzański 2022-02-14 14:35:46 UTC
Maybe its a different case but might be related
I attached screenshots of Eclipse IDE and DBeaver apps. BOth are unusable on my setup :
- plasma 5.24 on Opensuse Tumbleweed
- 4k screen
- 200%scaling

the issues you see on the screenshots are :
- decomposition of icons/menus
- unusable tables
- some scroll areas only take a quarter of the space available leaving remaining canvas unused/wasted
Comment 8 Vladislav Charickov 2022-03-15 21:06:21 UTC
I found a workaround

$ cat ~/.bash_profile 
export GDK_DPI_SCALE=0
export GDK_BACKEND=x11
export GDK_SCALE=1

 With variable GDK_BACKEND=x11 apps show up fine

See: https://wiki.archlinux.org/title/Wayland#XWayland
GTK
The gtk3 and gtk4 packages have the Wayland backend enabled. GTK will default to the Wayland backend, but it is possible to override it to Xwayland by modifying an environment variable: GDK_BACKEND=x11.
Comment 9 Dmitriy 2022-10-14 22:30:40 UTC
(In reply to Vladislav Charickov from comment #8)
> I found a workaround
> 
> $ cat ~/.bash_profile 
> export GDK_DPI_SCALE=0
> export GDK_BACKEND=x11
> export GDK_SCALE=1
> 
>  With variable GDK_BACKEND=x11 apps show up fine
> 
> See: https://wiki.archlinux.org/title/Wayland#XWayland
> GTK
> The gtk3 and gtk4 packages have the Wayland backend enabled. GTK will
> default to the Wayland backend, but it is possible to override it to
> Xwayland by modifying an environment variable: GDK_BACKEND=x11.

not working

Operating System: Arch Linux
KDE Plasma Version: 5.26.0
KDE Frameworks Version: 5.99.0
Qt Version: 5.15.6
Kernel Version: 6.0.1-arch1-1 (64-bit)
Graphics Platform: Wayland
Processors: 8 × Intel® Core™ i7-6820HK CPU @ 2.70GHz
Memory: 62.8 ГиБ of RAM
Graphics Processor: NVIDIA GeForce GTX 980M/PCIe/SSE2
Manufacturer: Micro-Star International Co., Ltd.
Product Name: GT72S 6QE
System Version: REV:1.0
Comment 10 Maciej Stanczew 2022-10-16 10:55:19 UTC
I just updated to Plasma 5.26, and I wanted to use the new "Legacy Applications (X11) scale by themselves" feature to get crisp scaling (instead of blurry system-wide one) in Steam (I'm running Wayland).

According to discussion[1], Steam will use GDK_SCALE if it's set, or determine correct scaling itself if GDK_SCALE is not set. I can confirm that: running either "GDK_SCALE=2; steam" or "unset GDK_SCALE; steam" produces correctly scaled UI (200% in my case).

However because Plasma overrides GDK_SCALE to 1, running just "steam" – or using the .desktop file – will result in UI scaled to 100%, which is definitely not what I would expect as a user.

[1] https://github.com/ValveSoftware/steam-for-linux/issues/4924
Comment 11 Bug Janitor Service 2022-10-28 14:06:33 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/2279
Comment 12 Dmitriy 2022-10-28 14:12:27 UTC
I've found small workaround to use GDK_SCALE and GDK_DPI_SCALE. Editing desktop entry files (*.desktop) helps. For example:

[Desktop Entry]
Name=FileZilla
GenericName=FTP client
GenericName[da]=FTP-klient
GenericName[de]=FTP-Client
GenericName[fr]=Client FTP
Comment=Download and upload files via FTP, FTPS and SFTP
Comment[da]=Download og upload filer via FTP, FTPS og SFTP
Comment[de]=Dateien über FTP, FTPS und SFTP übertragen
Comment[fr]=Transférer des fichiers via FTP, FTPS et SFTP
Exec=env GDK_DPI_SCALE=1.26 filezilla
Terminal=false
Icon=filezilla
Type=Application
Categories=Network;FileTransfer;
Version=1.0
Comment 13 Nate Graham 2022-11-02 17:50:09 UTC
Git commit 63de3d6f1716a6924fa5924b5a57af4abaa4460f by Nate Graham.
Committed on 02/11/2022 at 17:29.
Pushed by ngraham into branch 'master'.

startplasma-wayland: Don't set GDK_SCALE and GDK_DPI_SCALE

We did this to work around a bug whereby envars would be inappropriately
propagated when going from X11 to Wayland, causing GTK apps to be scaled
to too large a size

However this no longer appears to be an issue with any of the GTK apps I
tested (Blanket, Bustle, Cheese, Chromium, Firefox, Gedit, GIMP, GNOME
Sudoku, Inkscape, Peek, Video Downloader), and keeping it causes a bug
whereby non-GTK XWayland apps that perhaps inappropriately look at
these envars to determine their scale are scaled too small.

This hack has outlived its usefulness; let's kill it.
FIXED-IN: 5.26.3

M  +0    -3    startkde/startplasma-wayland.cpp

https://invent.kde.org/plasma/plasma-workspace/commit/63de3d6f1716a6924fa5924b5a57af4abaa4460f
Comment 14 Nate Graham 2022-11-02 18:01:21 UTC
Git commit 9ec6cf47a30fbdc4c64b7b0a0b4fb446f9d2904c by Nate Graham.
Committed on 02/11/2022 at 18:01.
Pushed by ngraham into branch 'Plasma/5.26'.

startplasma-wayland: Don't set GDK_SCALE and GDK_DPI_SCALE

We did this to work around a bug whereby envars would be inappropriately
propagated when going from X11 to Wayland, causing GTK apps to be scaled
to too large a size

However this no longer appears to be an issue with any of the GTK apps I
tested (Blanket, Bustle, Cheese, Chromium, Firefox, Gedit, GIMP, GNOME
Sudoku, Inkscape, Peek, Video Downloader), and keeping it causes a bug
whereby non-GTK XWayland apps that perhaps inappropriately look at
these envars to determine their scale are scaled too small.

This hack has outlived its usefulness; let's kill it.
FIXED-IN: 5.26.3


(cherry picked from commit 63de3d6f1716a6924fa5924b5a57af4abaa4460f)

M  +0    -3    startkde/startplasma-wayland.cpp

https://invent.kde.org/plasma/plasma-workspace/commit/9ec6cf47a30fbdc4c64b7b0a0b4fb446f9d2904c
Comment 15 Bug Janitor Service 2023-02-16 21:38:28 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/2635
Comment 16 Nate Graham 2023-02-16 21:45:44 UTC
Git commit 34e3efd85252182977178ab99435b99a1ba987b9 by Nate Graham.
Committed on 16/02/2023 at 21:43.
Pushed by ngraham into branch 'master'.

Revert "startplasma-wayland: Don't set GDK_SCALE and GDK_DPI_SCALE"

This reverts commit 63de3d6f1716a6924fa5924b5a57af4abaa4460f.

This change was incorrect and the original logic for it was backwards;
it was stated that keeping it causes non-GTK XWayland (e.g. Electron)
apps to be scaled incorrectly. But in fact the opposite was true;
getting rid of it was what causes them to be scaled incorrectly! This
mistake was made due to due to the presence of a loca workaround on my
system that inverted the behavior.
Related: bug 465733
FIXED-IN: 5.27.1

M  +6    -0    startkde/startplasma-wayland.cpp

https://invent.kde.org/plasma/plasma-workspace/commit/34e3efd85252182977178ab99435b99a1ba987b9
Comment 17 Nate Graham 2023-02-16 21:47:31 UTC
Git commit ba49bb121d7d6752b61aec29ae01a13e7978bd26 by Nate Graham.
Committed on 16/02/2023 at 21:47.
Pushed by ngraham into branch 'Plasma/5.27'.

Revert "startplasma-wayland: Don't set GDK_SCALE and GDK_DPI_SCALE"

This reverts commit 63de3d6f1716a6924fa5924b5a57af4abaa4460f.

This change was incorrect and the original logic for it was backwards;
it was stated that keeping it causes non-GTK XWayland (e.g. Electron)
apps to be scaled incorrectly. But in fact the opposite was true;
getting rid of it was what causes them to be scaled incorrectly! This
mistake was made due to due to the presence of a loca workaround on my
system that inverted the behavior.
Related: bug 465733
FIXED-IN: 5.27.1


(cherry picked from commit 34e3efd85252182977178ab99435b99a1ba987b9)

M  +6    -0    startkde/startplasma-wayland.cpp

https://invent.kde.org/plasma/plasma-workspace/commit/ba49bb121d7d6752b61aec29ae01a13e7978bd26
Comment 18 Nate Graham 2023-02-16 21:48:15 UTC
The change to fix this had to be reverted. Re-opening. Will find a better way to do it.
Comment 19 Bug Janitor Service 2023-02-16 22:06:38 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/2636
Comment 20 Maciej Stanczew 2023-02-16 23:33:12 UTC
Will there be a possibility to leave those variables unset, or to have them be automatically synchronized with KScreen's scale setting?
Steam correctly determines what scaling should it use when GDK_SCALE is not set. Having GDK_SCALE=1 breaks this, and Steam will be always scaled to 100%.
I could of course set GDK_SCALE=2 globally, but then it adds another place of maintenance -- if at any time I change the scaling in KScreen, I'll need to remember to also change it in GDK_SCALE.
I don't use any Electron apps, so I'd prefer to go with the simplest approach of unsetting GDK_SCALE. But now it seems it will be impossible, since those overrides are done after all the other variable-setting places are processed (e.g. /etc/profile or ~/.config/plasma-workspace/env).
Comment 21 Nate Graham 2023-02-17 00:17:50 UTC
With https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/2636, you'll be able to override it yourself.
Comment 22 Nate Graham 2023-02-17 00:18:28 UTC
You can also manually set it in the desktop files of apps that need it.
Comment 23 Nate Graham 2023-02-17 01:12:17 UTC
Git commit bd9c257dcdf050f74a691c31663cbca68ce8d8e7 by Nate Graham.
Committed on 17/02/2023 at 00:31.
Pushed by ngraham into branch 'master'.

startplasma-wayland: allow people to override GDK_* envars

Now that we're setting these ourselves again, we need to add the
ability to override them if needed. This commit does that.
FIXED-IN: 5.27.1

M  +8    -2    startkde/startplasma-wayland.cpp

https://invent.kde.org/plasma/plasma-workspace/commit/bd9c257dcdf050f74a691c31663cbca68ce8d8e7
Comment 24 Nate Graham 2023-02-17 01:12:49 UTC
Git commit 20c7e8826ca846b5155f17d628143e4546998c1c by Nate Graham.
Committed on 17/02/2023 at 01:12.
Pushed by ngraham into branch 'Plasma/5.27'.

startplasma-wayland: allow people to override GDK_* envars

Now that we're setting these ourselves again, we need to add the
ability to override them if needed. This commit does that.
FIXED-IN: 5.27.1


(cherry picked from commit bd9c257dcdf050f74a691c31663cbca68ce8d8e7)

M  +8    -2    startkde/startplasma-wayland.cpp

https://invent.kde.org/plasma/plasma-workspace/commit/20c7e8826ca846b5155f17d628143e4546998c1c
Comment 25 Maciej Stanczew 2023-02-17 05:30:00 UTC
> With https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/2636, you'll be able to override it yourself.
I'm looking for a way to unset the variables completely, not set them to a different value.

> You can also manually set it in the desktop files of apps that need it.
True, but very inelegant, to now have to manually edit .desktop files to revert a hack made for another application.

It looks like the only sensible solution is to recompile plasma-workspace with this change removed :/

Anyway, I'll go and submit a new bug report specifically for my use case with Steam, it'll be easier to handle it in isolation.
Comment 26 Bug Janitor Service 2023-02-18 09:27:21 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/2643
Comment 27 Fushan Wen 2023-02-18 09:49:44 UTC
Git commit cdf2e1a9abf7cdee24828f59aa7cc2295dee4877 by Fushan Wen.
Committed on 18/02/2023 at 09:28.
Pushed by fusionfuture into branch 'master'.

Revert "Revert "startplasma-wayland: Don't set GDK_SCALE and GDK_DPI_SCALE""

This reverts commit 34e3efd85252182977178ab99435b99a1ba987b9 and bd9c257dcdf050f74a691c31663cbca68ce8d8e7
Related: bug 465733

M  +0    -12   startkde/startplasma-wayland.cpp

https://invent.kde.org/plasma/plasma-workspace/commit/cdf2e1a9abf7cdee24828f59aa7cc2295dee4877
Comment 28 Fushan Wen 2023-02-18 09:50:40 UTC
Git commit 14c5b464f41f2b858453fd102ed57397755f9c26 by Fushan Wen.
Committed on 18/02/2023 at 09:50.
Pushed by fusionfuture into branch 'cherry-pick-cdf2e1a9'.

Revert "Revert "startplasma-wayland: Don't set GDK_SCALE and GDK_DPI_SCALE""

This reverts commit 34e3efd85252182977178ab99435b99a1ba987b9 and bd9c257dcdf050f74a691c31663cbca68ce8d8e7
Related: bug 465733


(cherry picked from commit cdf2e1a9abf7cdee24828f59aa7cc2295dee4877)

M  +0    -12   startkde/startplasma-wayland.cpp

https://invent.kde.org/plasma/plasma-workspace/commit/14c5b464f41f2b858453fd102ed57397755f9c26
Comment 29 Bug Janitor Service 2023-02-18 09:51:10 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/2644