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: Archlinux Linux
: NOR wishlist
Target Milestone: 1.0
Assignee: David Edmundson
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-10-02 05:38 UTC by Liu Zhe
Modified: 2022-11-02 18:02 UTC (History)
10 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.26.3


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