lapce / lapce

Lightning-fast and Powerful Code Editor written in Rust
http://lapce.dev
Apache License 2.0
34.44k stars 1.03k forks source link

Mouse pointer doesn't change icon. Sometime it doesn't even show up. #3345

Open HaoliangXu opened 4 months ago

HaoliangXu commented 4 months ago

Lapce Version

Latest version of both channels (Release, Nightly)

System information

Ubuntu 24.04

Describe the bug

Mouse pointer doesn't change icon on Lapce window. Sometime it doesn't even show up. Setting XCURSOR_THEME to a theme name works. But it should work without XCURSOR_THEME like other applications.

Additional information

Here's part of the log file:

2024-06-29T00:26:57.028873Z WARN floem_winit::platform_impl::platform::wayland::window::state: Failed to set cursor to Text
2024-06-29T00:26:57.029127Z WARN floem_winit::platform_impl::platform::wayland::window::state: Failed to set cursor to Default
2024-06-29T00:26:57.056644Z WARN floem_winit::platform_impl::platform::wayland::window::state: Failed to set cursor to Pointer
2024-06-29T00:26:57.073174Z WARN floem_winit::platform_impl::platform::wayland::window::state: Failed to set cursor to Default
2024-06-29T00:26:57.961110Z WARN floem_winit::platform_impl::platform::wayland::window::state: Failed to set cursor to Text
2024-06-29T00:26:58.232906Z WARN floem_winit::platform_impl::platform::wayland::window::state: Failed to set cursor to Default
2024-06-29T00:26:59.050246Z WARN floem_winit::platform_impl::platform::wayland::window::state: Failed to set cursor to Default
2024-06-29T00:26:59.128706Z WARN floem_winit::platform_impl::platform::wayland::window::state: Failed to set cursor to Text
2024-06-29T00:26:59.905073Z WARN floem_winit::platform_impl::platform::wayland::window::state: Failed to set cursor to Default
2024-06-29T00:27:01.073023Z WARN floem_winit::platform_impl::platform::wayland::window::state: Failed to set cursor to Default
2024-06-29T00:27:01.073157Z WARN floem_winit::platform_impl::platform::wayland::window::state: Failed to set cursor to RowResize
2024-06-29T00:27:01.081165Z WARN floem_winit::platform_impl::platform::wayland::window::state: Failed to set cursor to Default
2024-06-29T00:27:01.912919Z WARN floem_winit::platform_impl::platform::wayland::window::state: Failed to set cursor to Pointer
2024-06-29T00:27:01.929160Z WARN floem_winit::platform_impl::platform::wayland::window::state: Failed to set cursor to Default
2024-06-29T00:27:01.969070Z WARN floem_winit::platform_impl::platform::wayland::window::state: Failed to set cursor to Pointer
2024-06-29T00:27:02.057150Z WARN floem_winit::platform_impl::platform::wayland::window::state: Failed to set cursor to Default
2024-06-29T00:27:02.136882Z WARN floem_winit::platform_impl::platform::wayland::window::state: Failed to set cursor to Pointer
2024-06-29T00:27:02.645604Z WARN floem_winit::platform_impl::platform::wayland::window::state: Failed to set cursor to Default
2024-06-29T00:27:02.653183Z WARN floem_winit::platform_impl::platform::wayland::window::state: Failed to set cursor to Text

HaoliangXu commented 2 months ago

I found that it's mutter, a Wayland display server used by GNOME. mutter doesn't support WpCursorShapeManagerV1. So SCTK (depended by floem-winit) can only render cursor icon with legacy method. Coincidentally, mutter-46.0-ubuntu lost support for X11 cursor themes. And because Wayland_cursor::CursorTheme.fallback is "None", fallback cursor doesn't work either. That's why Lapce failed to set cursor to any shape.

However, I still can't find out why all other applications work alright.

HaoliangXu commented 2 months ago

I read the source code of Zed editor. When WpCursorShapeManagerV1 is not supported, instead of only reading XCURSOR_THEME from env, Zed also receives events from ashpd that provide current cursor theme, including real-time theme changes. That's why mouse works fine in Zed. I think other applications should be the same. Is there any way for Lapce to use ashpd also? Because I see it's in dependency tree.

HaoliangXu commented 2 months ago

If we bump winit to a newer version, the cursor will work but in a different theme("default" theme). I guess we need to add dbus access to floem to get the theme name from system.