Generate pre-scaled cursor files for those who don't use cursor-shape-v1
It seems that cursor-shape-v1 is "the path forward". However, according to https://wayland.app/protocols/cursor-shape-v1#compositor-support, currently only kwin implements it. So probably we won't see adoption in non-Qt apps very soon. And there are also X11 apps.
breeze!380 (merged) pre-scales the 24px Breeze cursor to global scaling factors up to 300% in 25% steps. It solves many cursor size issues in Wayland, especially in a fractional scale like 250%:
- Electron apps fallback to the closest match, so the cursor is slightly smaller, 48px (200%) in Wayland.
- GTK3 apps may have some bug in cursor scaling code, so the cursor is huge, like 900% in Wayland.
- GTK4 apps have the cursor in correct size. But they probably upscale from the 24px cursor, so it looks a little more blur than the cursor drawn by kwin, which upscales from 48px.
However, this approach has many limitations:
- It doesn't work if the user selects other cursor themes.
- It doesn't work if the user sets a larger cursor size, e.g. 36px, and a 300% scale. That would require a 108px cursor which we didn't pre-generate.
So I propose:
- Create a standalone executable that pre-scale the current cursor theme to the global scale factor.
- It should use the same scaling logic used by kwin (I guess it's https://invent.kde.org/plasma/kwin/-/blob/master/src/compositor_wayland.cpp?ref_type=heads#L272).
- It should scale the cursor to the current global scale, and to the integer scale for apps that don't support fractional scaling. (And probably also include a 1x version as fallback)
- It should generate the cursor theme in $XDG_DATA_HOME/icons. And that new theme will be set as the cursor theme, instead of what user selected.
- Whenever the user changes cursor theme, size, or global scale in systemsettings, the above executable is invoked.
- Other DE/compositors might use it too.
- To produce more crisp cursor images, that tool might optionally support generating cursors from SVGs, instead of upscaling from pixmaps.
Edited by Jin Liu