Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 838451 - gui-libs/gtk-4 doesn't look for /usr/share/cursors/xorg-x11/ path in wayland
Summary: gui-libs/gtk-4 doesn't look for /usr/share/cursors/xorg-x11/ path in wayland
Status: CONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Linux Gnome Desktop Team
URL: https://gitlab.gnome.org/GNOME/gtk/-/...
Whiteboard:
Keywords:
Depends on: 834277
Blocks:
  Show dependency tree
 
Reported: 2022-04-15 11:29 UTC by Johannes Penßel
Modified: 2024-03-14 09:26 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
emerge --info, gtk4-query-settings, printenv (file_838451.txt,14.22 KB, text/plain)
2022-04-15 11:29 UTC, Johannes Penßel
Details
journalctl output (file_838451.txt,112.82 KB, text/plain)
2022-04-15 11:38 UTC, Johannes Penßel
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Johannes Penßel 2022-04-15 11:29:55 UTC
Created attachment 770858 [details]
emerge --info, gtk4-query-settings, printenv

Probably the same as #836810 wich was assumed to be a system-specific issue rather than a bug and closed.

In GTK4 windows on Wayland, the mouse cursor becomes twice as big (roughly "medium" size in GNOME's accessibility settings) and does not change in shape anymore. It also disregards any configuration. 
I have observed this behaviour on two different machines, both running full ~amd64 and systemd, one with intel and the other with binary nvidia drivers. It happens on other Wayland-based WMs as well. (tested on the intel system for sanity)

Use cases that are NOT affected:

1. GTK4 apps on X11

2. GTK4-based flatpaks on Wayland

A quick test with Arch Linux shows that the issue does not occur there either.


Things I have tried so far:

1. changing cursor size in gnome-control-center

2. declaring gtk-cursor-theme-size = 24 in /etc/gtk-4.0/settings.ini as well as ~/.config/gtk-4.0/settings.ini

3. changing cursor size in gsettings via $ dconf write /org/gnome/desktop/interface/cursor-size 24 (normal and root)

4. exporting XCURSOR_SIZE=24 as environment variable in /etc/environment
Comment 1 Johannes Penßel 2022-04-15 11:38:50 UTC
Created attachment 770861 [details]
journalctl output
Comment 2 Johannes Penßel 2022-04-15 18:09:36 UTC
For testing purposes, I set up a completely new installation based on the stage3-systemd-desktop tarball, onto which I installed only wayfire and gnome-calculator as test bunny. On this setup, the issue did NOT occur. It also wasn't present after enabling ~amd64 and performing a full system upgrade. When I switched over to the systemd/gnome profile and rebuilt again, the problem was back. Something that's pulled in by the gnome profile seems to break GTK4.
Comment 3 Johannes Penßel 2022-04-15 19:17:37 UTC
Disregard the above. Looks like I initially forgot to set the wayland USE-flag on gui-libs/gtk. with it enabled, the cursor problem occurs even without the gnome profile.
Comment 4 Johannes Penßel 2022-04-15 20:09:52 UTC
I am pretty sure I figured it out now. Looks like x11-themes/adwaita-icon-theme installs cursor icons into /usr/share/cursors/xorg-x11/Adwaita/cursors. Apparently, GTK4 is unable to pick them up in this location on wayland and thus falls back to a 32x32 image cursor. 
This is made evident by the GTK4-Demos cursor demo, where all cursors work normally, except for the one that is supposed to show the current default and just displays the 32x32 fallback image cursor.
After copying /usr/share/cursors/xorg-x11/Adwaita/cursors into /usr/share/icons/Adwaita, all cursors are working flawlessly now.
Comment 5 Branko Grubic 2022-04-25 15:39:20 UTC
(In reply to Johannes P from comment #4)
> I am pretty sure I figured it out now. Looks like
> x11-themes/adwaita-icon-theme installs cursor icons into
> /usr/share/cursors/xorg-x11/Adwaita/cursors. Apparently, GTK4 is unable to
> pick them up in this location on wayland and thus falls back to a 32x32
> image cursor. 
> This is made evident by the GTK4-Demos cursor demo, where all cursors work
> normally, except for the one that is supposed to show the current default
> and just displays the 32x32 fallback image cursor.
> After copying /usr/share/cursors/xorg-x11/Adwaita/cursors into
> /usr/share/icons/Adwaita, all cursors are working flawlessly now.

Thanks for the workaround, helps a lot (cursors are sized properly and change depending on the "content" so applications are usable again, and it's easy to resize them (at least in Gnome))

For now I just created a symlink and it works! ;-)
Comment 6 Pacho Ramos gentoo-dev 2022-05-06 08:43:58 UTC
It seems this affects to all the cursor packs in Gentoo as we use /usr/share/cursors instead of /usr/share/icons... and it seems that is not common in other distributions:
https://github.com/flatpak/flatpak/issues/709#issuecomment-703239940

But, then, either we would need to carry a patch to add that location in Gentoo (probably forever as I am unsure if upstream would accept it) or also fix many other cursor packs in the tree that are using our "non-standard" location
Comment 7 Pacho Ramos gentoo-dev 2022-05-26 14:10:29 UTC
Other option (for the case we keep the traditional Gentoo location for the cursors) would be to at least add a symlink
Comment 8 Pacho Ramos gentoo-dev 2022-05-27 08:21:27 UTC
I tried to cover this (and other bugs) in the ebuild posted at
https://bugs.gentoo.org/844910#c4
Comment 9 Larry the Git Cow gentoo-dev 2022-05-27 21:20:14 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=3a95901e1a1b5dfe049b65b24933bcbefb65acc9

commit 3a95901e1a1b5dfe049b65b24933bcbefb65acc9
Author:     Pacho Ramos <pacho@gentoo.org>
AuthorDate: 2022-05-27 21:12:21 +0000
Commit:     Pacho Ramos <pacho@gentoo.org>
CommitDate: 2022-05-27 21:20:04 +0000

    x11-themes/adwaita-icon-theme: Package legacy icons and fix cursors path
    
    adwaita-icon-them dropped many legacy icons breaking many different
    applications. We were waiting for pieces to get fixed but, for now, it has
    turned into never ending disputed among different upstreams and breakage
    being kept for Gnome 42 cycle affecting many different apps.
    
    We follow Debian for now until this is better solved in the future in one
    way on another.
    
    Also keep upstream default location for cursor themes. Gentoo location is
    kept for backwards compatibility but that location is highly Gentoo
    specific. As a consequence, upstreams keep breaking in several ways and not
    fixing their apps to honour our PATH.
    
    Bug: https://bugs.gentoo.org/834277
    Bug: https://bugs.gentoo.org/834001
    Bug: https://bugs.gentoo.org/838451
    Bug: https://bugs.gentoo.org/844910
    Signed-off-by: Pacho Ramos <pacho@gentoo.org>

 x11-themes/adwaita-icon-theme/Manifest             |  2 +
 .../adwaita-icon-theme-42.0_p2.ebuild              | 97 ++++++++++++++++++++++
 2 files changed, 99 insertions(+)
Comment 10 amano.kenji 2023-08-05 05:58:35 UTC
I found a workaround for this issue.

Both gtk 3 and gtk 4 read cursor theme from gsettings.

import-gtk3-settings-into-gsettings
```
#!/bin/sh

# usage: import-gsettings
config="${XDG_CONFIG_HOME:-$HOME/.config}/gtk-3.0/settings.ini"
if [ ! -f "$config" ]; then exit 1; fi

gnome_schema="org.gnome.desktop.interface"
#gtk_theme="$(grep 'gtk-theme-name' "$config" | cut -d'=' -f2)"
#icon_theme="$(grep 'gtk-icon-theme-name' "$config" | cut -d'=' -f2)"
cursor_theme="$(grep 'gtk-cursor-theme-name' "$config" | cut -d'=' -f2)"
#font_name="$(grep 'gtk-font-name' "$config" | cut -d'=' -f2)"
#gsettings set "$gnome_schema" gtk-theme "$gtk_theme"
#gsettings set "$gnome_schema" icon-theme "$icon_theme"
gsettings set "$gnome_schema" cursor-theme "$cursor_theme"
#gsettings set "$gnome_schema" font-name "$font_name"
```

This script is sufficient for setting cursor theme for both gtk 3 and gtk 4. In the absence of gsettings and Settings d-bus portal, ~/.config/gtk-3.0 and ~/.config/gtk-4.0 will be consulted.

Because gtk 4 does not look up cursors in /usr/share/cursors/xorg-x11, I had to execute

```
ln -s /usr/share/cursors/x11-xorg ~/.local/share/icons
```
or
```
ln -s /usr/share/cursors/x11-xorg ~/.icons
```

With this, gtk 4 now uses the same cursor theme as gtk 3.
Comment 11 amano.kenji 2023-08-05 06:04:08 UTC
I think cursor packages should create symlinks from /usr/share/cursors/x11-xorg/THEME to /usr/share/icons/THEME.
Comment 12 Mart Raudsepp gentoo-dev 2024-03-02 22:22:52 UTC
We should fix all our cursor packages to install in the right place, not a xorg-x11 location, but no-one seems to have pushed for that yet?

Saying this as I was contemplating of why the cursors location patch in gnome-tweaks was dropped and was about to bring it back as it seemed to find more cursors that I installed that only go to xorg-x11, but fortunately found this bug first and found that it'd be broken for gtk4, thus we should indeed not advertise xorg-x11 path cursors in gnome-tweaks as-is.