fix(ui): avoid duplicate cursor without Wayland theme

This commit is contained in:
Ammar Almakzumi
2026-11-05 10:54:45 +07:00
committed by bflatastic
parent dfc0f28004
commit 822e4669ce
3 changed files with 10 additions and 9 deletions
+1 -1
View File
@@ -460,7 +460,7 @@ fn canvas_cursor(app: &mut VectorcraftApp, ui: &Ui, view_info: vectorcraft_engin
}
Some(hp)
if custom
&& crate::cursors::paint_glyphs(crate::cursors::HIDES_ONLY_WHEN_KEY, ui.input(|i| i.focused))
&& crate::cursors::paint_glyphs(crate::cursors::HIDES_ONLY_WHEN_KEY, ui.input(|i| i.focused), app.services.no_cursor_theme)
&& crate::cursors::paint(&painter, c, hp, 1.0 / ui_scale) =>
{
// No cursor theme (Wayland): the glyph is painted, the system pointer stays (#2450).
+5 -5
View File
@@ -714,11 +714,11 @@ pub fn hide_system_pointer(no_cursor_theme: bool) -> bool {
/// Over a window behind another app or under a sheet, the system pointer shows (#2020).
pub const HIDES_ONLY_WHEN_KEY: bool = cfg!(target_os = "macos");
/// Does the window paint the glyphs over a hidden pointer, `focused` or not? Not where the system
/// shows its pointer over a window without the focus ([`HIDES_ONLY_WHEN_KEY`]): the system pointer
/// shows alone there.
pub fn paint_glyphs(hides_only_when_key: bool, focused: bool) -> bool {
focused || !hides_only_when_key
/// Does the window paint a glyph over a hidden pointer? Not where it cannot hide the system pointer
/// (no cursor theme on Wayland), or where the system shows its pointer without the focus
/// ([`HIDES_ONLY_WHEN_KEY`]): the system pointer shows alone there.
pub fn paint_glyphs(hides_only_when_key: bool, focused: bool, no_cursor_theme: bool) -> bool {
!no_cursor_theme && (focused || !hides_only_when_key)
}
/// The cursor bitmaps handed to the OS, by (cursor, pixels per point): each glyph is rasterized
+4 -3
View File
@@ -472,9 +472,10 @@ fn wayland_windows_paint_the_glyphs() {
#[test]
fn macos_windows_paint_the_glyphs_only_with_the_focus() {
assert!(paint_glyphs(true, true), "macOS with the focus");
assert!(!paint_glyphs(true, false), "macOS without the focus: the system pointer shows (#2020)");
assert!(paint_glyphs(false, true) && paint_glyphs(false, false), "Wayland, the web: painted with the focus or without");
assert!(paint_glyphs(true, true, false), "macOS with the focus");
assert!(!paint_glyphs(true, false, false), "macOS without the focus: the system pointer shows (#2020)");
assert!(paint_glyphs(false, true, false) && paint_glyphs(false, false, false), "Wayland, the web: painted with the focus or without");
assert!(!paint_glyphs(false, true, true), "without a cursor theme, use the system pointer alone");
}
#[test]