ZIm/crates
tims d609931e1c
linux: Fix mouse cursor size and blur on Wayland (#21373)
Closes #15788, #13258

This is a long-standing issue with a few previous attempts to fix it,
such as [this one](https://github.com/zed-industries/zed/pull/17496).
However, that fix was later reverted because it resolved the blur issue
but caused a size issue. Currently, both blur and size issues persist
when you set a custom cursor size from GNOME Settings and use fractional
scaling.

This PR addresses both issues.

---

### Context

A new Wayland protocol,
[cursor-shape-v1](https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/194),
allows the compositor to handle rendering the cursor at the correct size
and shape. This protocol is implemented by KDE, wlroots (Sway-like
environments), etc. Zed supports this protocol, so there are no issues
on these desktop environments.

However, GNOME has not yet
[adopted](https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/6212) this
protocol. As a result, apps must fall back to manually rendering the
cursor by specifying the theme, size, scale, etc., themselves. Zed also
implements this fallback but does not correctly account for the display
scale.

---

### Scale Fix

For example, if your cursor size is `64px` and you’re using fractional
scaling (e.g., `150%`), the display scale reported by the window query
will be an integer value, `2` in this case. Why `2` if the scale is
`150%`? That’s what the new protocol aims to improve. However, since
GNOME Wayland uses this integer scale everywhere, it’s sufficient for
our use case.

To fix the issue, we set the `buffer_scale` to this value. But that
alone doesn’t solve the problem. We also need to generate a matching
theme cursor size for this scaled version. This can be calculated as
`64px` * `2`, resulting in `128px` as the theme cursor size.

---

### Size Fix

The XDG Desktop Portal’s `cursor-size` event fails to read the cursor
size because it expects an `i32` but encounters a type error with `u32`.
Due to this, the cursor size was interpreted as the default `24px`
instead of the actual size set via user.

---

### Tested

This fix has been tested with all possible combinations of the
following:

- [x] GNOME Normal Scale (100%, 200%, etc.)
- [x] GNOME Fractional Scaling (125%, 150%, etc.)
- [x] GNOME Cursor Sizes (**Settings > Accessibility > Seeing**, e.g.,
`24px`, `64px`, etc.)
- [x] GNOME Experimental Feature `scale-monitor-framebuffer` (both
enabled and disabled)
- [x] KDE (`cursor-shape-v1` protocol)

---

**Result:**

64px custom cursor size + 150% Fractional Scale:


https://github.com/user-attachments/assets/cf3b1a0f-9a25-45d0-ab03-75059d3305e7

---

Release Notes:

- Fixed mouse cursor size and blur issues on Wayland
2024-11-30 13:19:44 -08:00
..
activity_indicator language servers: Fix wrong language server name (#20428) 2024-11-11 10:18:38 +01:00
anthropic assistant: Remove low_speed_timeout (#20681) 2024-11-15 07:37:31 +01:00
assets add ui::Vector and separate images from icons (#17815) 2024-09-13 17:44:16 -04:00
assistant Make fetch slash command visible in the command selector (#21302) 2024-11-28 18:26:59 -03:00
assistant2 assistant2: Add a checkbox to control tool use (#21215) 2024-11-26 10:48:48 -05:00
assistant_slash_command Overhaul extension registration (#21083) 2024-11-22 19:02:32 -05:00
assistant_tool Factor tool definitions out of assistant (#21189) 2024-11-25 18:26:34 -05:00
assistant_tools assistant2: Add support for using tools (#21190) 2024-11-25 19:44:34 -05:00
audio Update Rust crate rodio to 0.20.0 (#20955) 2024-11-28 10:58:36 +02:00
auto_update Extract auto_update_ui crate (#21008) 2024-11-21 14:11:57 -05:00
auto_update_ui Extract auto_update_ui crate (#21008) 2024-11-21 14:11:57 -05:00
breadcrumbs Add missing shortcuts in tooltips (#18282) 2024-09-27 11:06:48 +02:00
call Revert "Use livekit's Rust SDK instead of their swift SDK (#13343)" (#20809) 2024-11-18 11:43:53 +02:00
channel Use Instant not chrono for telemetry (#20756) 2024-11-19 08:23:12 -07:00
cli Update Rust crate ipc-channel to 0.19 (#20951) 2024-11-28 10:58:10 +02:00
client Send llm events to snowflake too (#21091) 2024-11-22 20:40:39 -07:00
clock Use Instant not chrono for telemetry (#20756) 2024-11-19 08:23:12 -07:00
collab Factor tool definitions out of assistant (#21189) 2024-11-25 18:26:34 -05:00
collab_ui collab_ui: Remove dependency on vcs_menu (#21016) 2024-11-21 15:48:35 -05:00
collections gpui: Add SVG rendering to img element and generic asset cache (#9931) 2024-03-29 17:09:49 -07:00
command_palette title_bar: Remove dependency on command_palette (#21006) 2024-11-21 13:37:34 -05:00
command_palette_hooks Improve context server lifecycle management (#20622) 2024-11-13 13:55:06 -08:00
context_server Factor tool definitions out of assistant (#21189) 2024-11-25 18:26:34 -05:00
context_server_settings Factor tool definitions out of assistant (#21189) 2024-11-25 18:26:34 -05:00
copilot Add fs::MTime newtype to encourage != instead of > (#20830) 2024-11-21 19:21:18 -07:00
db chore: Fix some violations of 'needless_pass_by_ref_mut' lint (#18795) 2024-10-07 01:29:58 +02:00
diagnostics Fine-tune status bar left-side spacing (#21306) 2024-11-28 19:15:30 -03:00
docs_preprocessor Don't rely on relative path for docs preprocessor (#16883) 2024-08-26 11:43:13 -04:00
editor Fix the autoscroll_on_clicks setting working incorrectly (#21362) 2024-11-30 14:30:27 +02:00
evals windows: Set CREATE_NO_WINDOW for commands (#18447) 2024-11-20 16:52:38 -08:00
extension Overhaul extension registration (#21083) 2024-11-22 19:02:32 -05:00
extension_api zed_extension_api: Release v0.2.0 (#20683) 2024-11-14 12:44:10 -05:00
extension_cli Add new extension crate (#20089) 2024-11-01 13:20:30 -04:00
extension_host Factor tool definitions out of assistant (#21189) 2024-11-25 18:26:34 -05:00
extensions_ui Overhaul extension registration (#21083) 2024-11-22 19:02:32 -05:00
feature_flags assistant2: Add support for using tools (#21190) 2024-11-25 19:44:34 -05:00
feedback title_bar: Remove dependency on feedback (#21013) 2024-11-21 15:24:04 -05:00
file_finder Fix file finder menu actions (#21087) 2024-11-23 02:21:19 +02:00
file_icons chore: Clean up allocs around project panel (#15422) 2024-07-29 14:21:41 +02:00
fs Better absolute path handling (#19727) 2024-11-27 20:22:58 +02:00
fsevent Retain run loop (#11241) 2024-04-30 23:31:59 -06:00
fuzzy Improve slash commands (#16195) 2024-08-13 23:06:07 -07:00
git windows: Set CREATE_NO_WINDOW for commands (#18447) 2024-11-20 16:52:38 -08:00
git_hosting_providers git_hosting_providers: Fix support for GitLab remotes containing subgroups (#19962) 2024-10-30 11:16:44 -04:00
go_to_line Add a keybinding to the Go to Line button (#21350) 2024-11-30 00:50:38 +02:00
google_ai assistant: Remove low_speed_timeout (#20681) 2024-11-15 07:37:31 +01:00
gpui linux: Fix mouse cursor size and blur on Wayland (#21373) 2024-11-30 13:19:44 -08:00
gpui_macros add ui::Vector and separate images from icons (#17815) 2024-09-13 17:44:16 -04:00
html_to_markdown chore: Fix several style lints (#17488) 2024-09-06 11:58:39 +02:00
http_client Revert "Use livekit's Rust SDK instead of their swift SDK (#13343)" (#20809) 2024-11-18 11:43:53 +02:00
image_viewer project-panel: Fix playback GIF images (#21274) 2024-11-28 03:20:10 -08:00
indexed_docs Overhaul extension registration (#21083) 2024-11-22 19:02:32 -05:00
inline_completion Extract InlineCompletionProvider to its own crate (#20935) 2024-11-20 16:51:13 -05:00
inline_completion_button language_model: Remove dependency on inline_completion_button (#20930) 2024-11-20 16:19:20 -05:00
install_cli Fix flickering (#9012) 2024-03-11 10:45:57 +01:00
journal chore: Fix several style lints (#17488) 2024-09-06 11:58:39 +02:00
language Enable clangd's dot-to-arrow feature (#21142) 2024-11-28 10:43:25 +02:00
language_extension pylsp: Prefer version from user venv (#21069) 2024-11-25 00:54:47 +01:00
language_model assistant2: Restructure storage of tool uses and results (#21194) 2024-11-25 21:53:27 -05:00
language_model_selector Factor out language model selector into its own crate (#21113) 2024-11-23 12:11:31 -05:00
language_models assistant2: Restructure storage of tool uses and results (#21194) 2024-11-25 21:53:27 -05:00
language_selector Use a single action for toggling the language (#21331) 2024-11-29 16:02:57 +02:00
language_tools Expose active key equivalents in the keymap context view (#20530) 2024-11-11 23:04:15 -07:00
languages Improve JavaScript runnable detection followup (#21363) 2024-11-30 13:55:14 +01:00
live_kit_client Revert "Use livekit's Rust SDK instead of their swift SDK (#13343)" (#20809) 2024-11-18 11:43:53 +02:00
live_kit_server Restore HTTP client transition, but use reqwest everywhere (#19055) 2024-10-11 14:58:58 -07:00
lsp Enable clangd's dot-to-arrow feature (#21142) 2024-11-28 10:43:25 +02:00
markdown Add initial FreeBSD support (#20480) 2024-11-11 18:39:05 +01:00
markdown_preview Make Markdown images layout vertically instead of horizontally (#21247) 2024-11-27 10:47:23 -08:00
media Revert "Use livekit's Rust SDK instead of their swift SDK (#13343)" (#20809) 2024-11-18 11:43:53 +02:00
menu open picker (#14524) 2024-07-15 17:04:15 -06:00
multi_buffer Add File.disk_state enum to clarify filesystem states (#20776) 2024-11-18 10:30:08 -08:00
node_runtime windows: Set CREATE_NO_WINDOW for commands (#18447) 2024-11-20 16:52:38 -08:00
notifications Markdown preview image rendering (#21082) 2024-11-22 14:49:26 -08:00
ollama Fix inaccurate Ollama context length for qwen2.5 models (#20933) 2024-11-22 10:10:01 -05:00
open_ai assistant: Remove low_speed_timeout (#20681) 2024-11-15 07:37:31 +01:00
outline Revert "remove usages of theme::color_alpha" 2024-11-19 00:24:48 -05:00
outline_panel Remove assistant hints (#21171) 2024-11-25 17:19:33 +01:00
paths Add initial FreeBSD support (#20480) 2024-11-11 18:39:05 +01:00
picker toolchains: Use language-specific terms in UI (#20985) 2024-11-21 15:57:22 +01:00
prettier Add more common Prettier plugin base paths (#20758) 2024-11-16 13:20:52 +02:00
project search: Treat non-word char as whole-char when searching (#19152) 2024-11-28 11:06:48 +02:00
project_panel Remove project panel trash action for remote projects (#21300) 2024-11-29 22:37:24 +02:00
project_symbols Fix renames over language server for SSH remoting (#17897) 2024-09-16 16:20:17 -06:00
proto toolchains: Expose raw JSON representation of a toolchain (#20721) 2024-11-21 13:27:25 +01:00
recent_projects Remove assistant hints (#21171) 2024-11-25 17:19:33 +01:00
refineable Move Clippy configuration to the workspace level (#8891) 2024-03-05 12:01:17 -05:00
release_channel chore: Fix several style lints (#17488) 2024-09-06 11:58:39 +02:00
remote Fix panics from spawn_local tasks dropped on other threads in remote server (#21022) 2024-11-21 14:50:38 -07:00
remote_server Overhaul extension registration (#21083) 2024-11-22 19:02:32 -05:00
repl Upgrade jupyter websocket client (#21095) 2024-11-22 22:11:20 -08:00
reqwest_client assistant: Remove low_speed_timeout (#20681) 2024-11-15 07:37:31 +01:00
rich_text Markdown preview image rendering (#21082) 2024-11-22 14:49:26 -08:00
rope rope: Minor optimization for tab indices (#20911) 2024-11-21 08:48:13 +01:00
rpc Add support for git branches on remote projects (#19755) 2024-10-27 15:50:54 -07:00
search Make project search landing page scrollable if too small (#21338) 2024-11-29 12:45:08 -03:00
semantic_index Add fs::MTime newtype to encourage != instead of > (#20830) 2024-11-21 19:21:18 -07:00
semantic_version Extract SemanticVersion into its own crate (#9956) 2024-03-29 12:11:57 -04:00
session chore: Fix some violations of 'needless_pass_by_ref_mut' lint (#18795) 2024-10-07 01:29:58 +02:00
settings Fix keybindings on a Spanish ISO keyboard (#20995) 2024-11-21 10:18:54 -07:00
settings_ui Revert "theme: Turn ThemeRegistry into a trait (#20076)" (#20094) 2024-11-01 15:34:20 -04:00
snippet Snippet choices (#13958) 2024-11-18 22:56:34 +01:00
snippet_provider Overhaul extension registration (#21083) 2024-11-22 19:02:32 -05:00
snippets_ui Add snippet commands (#18453) 2024-10-02 13:27:16 +02:00
sqlez Add initial FreeBSD support (#20480) 2024-11-11 18:39:05 +01:00
sqlez_macros Add initial FreeBSD support (#20480) 2024-11-11 18:39:05 +01:00
story chore: Fix several style lints (#17488) 2024-09-06 11:58:39 +02:00
storybook Add preview for Checkbox with Label (#20448) 2024-11-08 22:53:15 -05:00
sum_tree Speed up point translation in the Rope (#19913) 2024-10-30 10:59:03 +01:00
supermaven windows: Set CREATE_NO_WINDOW for commands (#18447) 2024-11-20 16:52:38 -08:00
supermaven_api chore: Fix several style lints (#17488) 2024-09-06 11:58:39 +02:00
tab_switcher tab_switcher: Use git-aware colors for file icons (#18733) 2024-10-04 10:37:41 -04:00
task Add the option to hide both the task and command lines in the task output (#20920) 2024-11-22 13:45:42 -05:00
tasks_ui chore: Sever terminal_view <-> tasks_ui dependency (#20946) 2024-11-21 01:07:14 +01:00
telemetry_events Start to send data to Snowflake too (#20698) 2024-11-15 12:58:00 -07:00
terminal Add the option to hide both the task and command lines in the task output (#20920) 2024-11-22 13:45:42 -05:00
terminal_view Allow workspace::ActivatePaneInDirection to navigate out of the terminal panel (#21313) 2024-11-29 13:04:58 +02:00
text Fix a test flake involving zeroed out group_intervals (#20328) 2024-11-07 09:17:43 -07:00
theme Revert "remove usages of theme::color_alpha" 2024-11-19 00:24:48 -05:00
theme_extension Overhaul extension registration (#21083) 2024-11-22 19:02:32 -05:00
theme_importer chore: Another round of style lints fixes (#17519) 2024-09-07 02:36:55 +02:00
theme_selector title_bar: Remove dependency on theme_selector (#21009) 2024-11-21 14:33:58 -05:00
time_format chore: Fix several style lints (#17488) 2024-09-06 11:58:39 +02:00
title_bar title_bar: Remove dependency on feedback (#21013) 2024-11-21 15:24:04 -05:00
toolchain_selector toolchains: Use language-specific terms in UI (#20985) 2024-11-21 15:57:22 +01:00
ui Make fetch slash command visible in the command selector (#21302) 2024-11-28 18:26:59 -03:00
ui_input Rename ui_text_field crate to ui_input (#13949) 2024-07-08 17:05:30 -04:00
ui_macros Fix DynamicSpacing docs (#20509) 2024-11-11 12:58:39 -05:00
util Better absolute path handling (#19727) 2024-11-27 20:22:58 +02:00
vcs_menu title_bar: Remove dependency on vcs_menu (#21011) 2024-11-21 14:56:02 -05:00
vim Add ctrl-w _ and ctrl-w = (#21227) 2024-11-26 16:45:38 -08:00
vim_mode_setting Extract VimModeSetting to its own crate (#21019) 2024-11-21 16:24:38 -05:00
welcome welcome: Remove dependency on theme_selector (#21024) 2024-11-21 17:50:22 -05:00
workspace Status bar: Reduce right tools lateral margin (#21329) 2024-11-29 10:56:32 -03:00
worktree Better absolute path handling (#19727) 2024-11-27 20:22:58 +02:00
zed linux: Fix Zed not visible in "Open With" list in file manager for Flatpak (#21177) 2024-11-29 22:59:04 +02:00
zed_actions title_bar: Remove dependency on feedback (#21013) 2024-11-21 15:24:04 -05:00