diff --git a/Cargo.toml b/Cargo.toml index a0c09a383d..2d55e346f4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -106,7 +106,7 @@ rfd = "0.17" muda = { version = "0.21", default-features = false } # native menu bar (macOS: objc2/AppKit, pure Rust; no GTK) # macOS: the profile of the screen showing the window (safe AppKit bindings; muda and wgpu use the same) objc2 = { version = "0.6", default-features = false, features = ["std"] } -objc2-app-kit = { version = "0.3", default-features = false, features = ["std", "NSApplication", "NSAccessibility", "NSColorSpace", "NSResponder", "NSScreen", "NSWindow", "NSWorkspace"] } +objc2-app-kit = { version = "0.3.2", default-features = false, features = ["std", "NSApplication", "NSAccessibility", "NSColorSpace", "NSResponder", "NSScreen", "NSWindow", "NSWorkspace"] } objc2-foundation = { version = "0.3", default-features = false, features = ["std", "NSArray", "NSData"] } # Linux: the desktop's dark/light setting from the XDG settings portal (Settings ▸ Interface ▸ # Appearance Mode ▸ Auto). Pure Rust; the version accesskit already brings in, pinned to it. diff --git a/crates/ui-egui/src/menus/run.rs b/crates/ui-egui/src/menus/run.rs index 054079add8..346e93f727 100644 --- a/crates/ui-egui/src/menus/run.rs +++ b/crates/ui-egui/src/menus/run.rs @@ -351,11 +351,11 @@ fn ui_commands_2(app: &mut LightcraftApp, ctx: &egui::Context, id: &str, p: &Val "view.reduceMotion" => { // {on?} sets it; {follow: true} goes back to the system's Reduce Motion; no params toggles // what is in effect. Zoom and spinner animations stop; fades stay. - app.ui.settings.reduce_motion = if p.get("follow").and_then(Value::as_bool) == Some(true) { - None - } else { - Some(p.get("on").and_then(Value::as_bool).unwrap_or(!app.reduce_motion())) + let (follow, on) = match (bool_param(id, p, "follow"), bool_param(id, p, "on")) { + (Ok(follow), Ok(on)) => (follow, on), + (Err(e), _) | (_, Err(e)) => return Some(Err(e)), }; + app.ui.settings.reduce_motion = if follow == Some(true) { None } else { Some(on.unwrap_or(!app.reduce_motion())) }; Ok(json!({"on": app.reduce_motion(), "followsSystem": app.ui.settings.reduce_motion.is_none()})) } "view.faceBoxes" => { diff --git a/crates/ui-egui/src/tests/reduce_motion.rs b/crates/ui-egui/src/tests/reduce_motion.rs index f22ce5e44d..cd7845557b 100644 --- a/crates/ui-egui/src/tests/reduce_motion.rs +++ b/crates/ui-egui/src/tests/reduce_motion.rs @@ -104,6 +104,23 @@ fn the_command_toggles_and_sets_the_setting() { assert_eq!(run(&mut h, "view.reduceMotion", json!({"on": false}))["on"], false); } +#[test] +fn the_command_refuses_params_that_are_not_true_or_false_and_changes_nothing() { + let mut h = detail(); + run(&mut h, "view.reduceMotion", json!({"on": true})); + for (params, says) in [ + (json!({"on": "false"}), "`on` must be true or false"), + (json!({"on": 0}), "`on` must be true or false"), + (json!({"follow": "yes"}), "`follow` must be true or false"), + (json!({"follow": 1, "on": false}), "`follow` must be true or false"), + ] { + let r = h.request("engine.execute", json!({"command": "view.reduceMotion", "params": params}), T); + assert_eq!(r["ok"], false, "{params}: {r}"); + assert!(r.to_string().contains(says), "{params}: {r}"); + assert_eq!(h.app.ui.settings.reduce_motion, Some(true), "{params} changed the setting"); + } +} + #[test] fn egui_easing_stops_with_reduce_motion_on_and_returns_when_off() { let mut h = detail();