From 4eb36873d4ca4b0faf0e54dbeab8f5f6450dd704 Mon Sep 17 00:00:00 2001 From: srdusr <99972264+srdusr@users.noreply.github.com> Date: Fri, 3 Oct 2025 22:59:00 +0200 Subject: Make the secondary-cursor sprite opt-in and expire stale entries Live report: a second cursor appeared uninvited and unusably (frozen, uncontrollable) on screen. Multi-cursor Phase 1 rendered one sprite per physical libinput pointer device that had ever reported a position, with no way to turn it off and no expiry - so a phantom device (a real mouse's side-button/scroll cluster enumerating as its own HID path is a common case) that reports once and never moves again left a frozen ghost sprite with nothing to control or dismiss it. Adds general.multi_cursor (default false, live-settable via `srd set multi_cursor `) and keys secondary_cursors to (Point, Instant) so both the recording side (udev/session.rs) and the render side (udev/render.rs) drop any entry older than SECONDARY_CURSOR_TIMEOUT (1.5s). The "agent controls a window without interrupting the user" use case this report also raised was never gated on this flag - that's Multi-cursor Phase 2's pinned virtual-pointer delivery, which never shows a visible cursor at all. --- crates/ctl/src/main.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'crates/ctl') diff --git a/crates/ctl/src/main.rs b/crates/ctl/src/main.rs index d714405..3cf3bfd 100644 --- a/crates/ctl/src/main.rs +++ b/crates/ctl/src/main.rs @@ -178,14 +178,14 @@ fn build_request(args: &[String]) -> Result { // as booleans at all, not a string it then has to reject. Some("set") => { let key = args.get(1).ok_or( - "set needs a key (border_width/border_color/corner_radius/gap_inner/gap_outer/shadows/rounded_corners/animations/night_light/reading_mode/phone_mode/decoration_mode)", + "set needs a key (border_width/border_color/corner_radius/gap_inner/gap_outer/shadows/rounded_corners/animations/night_light/reading_mode/phone_mode/multi_cursor/decoration_mode)", )?; let raw = args.get(2).ok_or("set needs a value")?; let value = match key.as_str() { "border_width" | "corner_radius" | "gap_inner" | "gap_outer" => { raw.parse::().map_err(|_| format!("{key} needs a numeric value"))?.to_string() } - "shadows" | "rounded_corners" | "animations" | "night_light" | "reading_mode" | "phone_mode" => match raw.as_str() { + "shadows" | "rounded_corners" | "animations" | "night_light" | "reading_mode" | "phone_mode" | "multi_cursor" => match raw.as_str() { "true" | "false" => raw.clone(), _ => return Err(format!("{key} needs 'true' or 'false'")), }, @@ -401,6 +401,7 @@ fn print_usage() { eprintln!(" srd set night_light "); eprintln!(" srd set reading_mode "); eprintln!(" srd set phone_mode "); + eprintln!(" srd set multi_cursor "); eprintln!(" srd set decoration_mode "); } @@ -478,6 +479,13 @@ mod tests { assert!(build_request(&args(&["dispatch", "set", "output", "position", "1", "not-a-number", "0"])).is_err()); } + #[test] + fn set_multi_cursor_accepts_only_true_or_false() { + assert_eq!(build_request(&args(&["set", "multi_cursor", "true"])).unwrap(), r#"{"cmd":"set","key":"multi_cursor","value":true}"#); + assert_eq!(build_request(&args(&["set", "multi_cursor", "false"])).unwrap(), r#"{"cmd":"set","key":"multi_cursor","value":false}"#); + assert!(build_request(&args(&["set", "multi_cursor", "maybe"])).is_err()); + } + #[test] fn set_phone_mode_accepts_only_true_or_false() { assert_eq!(build_request(&args(&["set", "phone_mode", "true"])).unwrap(), r#"{"cmd":"set","key":"phone_mode","value":true}"#); -- cgit v1.2.3