Turn one illustration into an animated 2D mesh avatar with a coding agent and a local editor
Add a menu-bar status icon to the desktop avatar
shinshin861a79c3ddccd5
diff --git a/native/Cargo.lock b/native/Cargo.lockindex f5f0e3e..8f01b9e 100644--- a/native/Cargo.lock+++ b/native/Cargo.lock@@ -978,6 +978,7 @@ dependencies = ["rfd","serde","serde_json",+ "tray-icon","wgpu","winit",]@@ -1248,6 +1249,16 @@ dependencies = ["objc2 0.6.5",]+[[package]]+name = "objc2-core-graphics"+version = "0.3.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e022c9d066895efa1345f8e33e584b9f958da2fd4cd116792e15e07e4720a807"+dependencies = [+ "bitflags 2.13.2",+ "objc2-core-foundation",+]+[[package]]name = "objc2-core-image"version = "0.2.2"@@ -1298,6 +1309,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "e3e0adef53c21f888deb4fa59fc59f7eb17404926ee8a6f59f5df0fd7f9f3272"dependencies = ["bitflags 2.13.2",+ "block2 0.6.2","objc2 0.6.5","objc2-core-foundation",]@@ -2091,6 +2103,26 @@ version = "0.1.36"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a"+[[package]]+name = "tray-icon"+version = "0.24.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "045979e3f037cd18ad1cb2a419dfda133c5c29c9f3453370079f2255d46c257e"+dependencies = [+ "crossbeam-channel",+ "dirs",+ "muda",+ "objc2 0.6.5",+ "objc2-app-kit 0.3.2",+ "objc2-core-foundation",+ "objc2-core-graphics",+ "objc2-foundation 0.3.2",+ "once_cell",+ "png 0.18.1",+ "thiserror 2.0.21",+ "windows-sys 0.61.2",+]+[[package]]name = "ttf-parser"version = "0.25.1"diff --git a/native/README.ja.md b/native/README.ja.mdindex 43bd109..d74bca9 100644--- a/native/README.ja.md+++ b/native/README.ja.md@@ -72,8 +72,15 @@ macOSでは **Avatar → Motion** からすべてのモーションを名前で| Escape または Command + `Q` | 終了する |操作は、アバターのアプリにキーボードフォーカスがあるときに有効です。クリック透過をオンにすると、マウス操作は下のウィンドウに届きます。-オフに戻すには、Dock か Command-Tab でアバターのアプリにフォーカスを戻してから `C` を押します。このキーはグローバルショートカットではありません。-フォーカスを戻せない場合は Dock から終了して起動し直してください。クリック透過は起動時に必ずオフになります。+macOSでは、システムのステータスバーにある単色のアバターアイコンからメニューを開けます。**Hide Avatar / Show Avatar** でアバターの表示・非表示を切り替えます。アバターを隠しても、このアイコンは残ります。+**Click-through** はオンのときにチェックがつき、アバターにフォーカスを戻さずにオフにできます。`C` キーの操作も同じチェック表示に反映されます。++ステータスメニューには **Open Avatar…**、アプリメニューと同じ **Open Recent**、**Quit Mesh Avatar** もあります。+ここからアバターを開くと、先にアバターのウィンドウを表示します。ファイル選択をキャンセルした場合も表示したままです。+非表示中はアバターを読み込んだまま描画を止めます。表示・非表示とクリック透過の状態は保存せず、次回起動時はアバターを表示し、クリック透過はオフになります。++ステータスバーのアイコンを使えない場合は、DockかCommand-Tabでアプリにフォーカスを戻してから `C` を押します。このキーはグローバルショートカットではありません。+フォーカスを戻せない場合はDockから終了して起動し直してください。待機中の動き、まばたき、呼吸、ときどき入るモーションは自動で再生されます。描画はディスプレイの表示レートに合わせます。リサイズやモニターの拡大率の変更に合わせて実際の描画サイズを更新し、処理が止まったりスリープから復帰したりした後のアニメーションの時間刻みは 0.05 秒までに抑えます。@@ -110,7 +117,7 @@ dump は、Rust 側に埋め込んだモーションデータが JavaScript の- Windows と Linux のデスクトップでの動作は確認していません。ウィンドウの透明化、最前面表示、クリック透過は OS のコンポジタに依存します。透明な描画面を使えない環境では、アプリは終了します。-- メニューバーと Open Avatar ダイアログは macOS 専用です。実行ファイルには、アプリバンドルなしで「Mesh Avatar」という名前を埋め込んでいます。+- メニューバー、ステータスバーのアイコン、Open Avatar ダイアログは macOS 専用です。実行ファイルには、アプリバンドルなしで「Mesh Avatar」という名前を埋め込んでいます。macOS がほかの場所で表示する名前は、起動のしかたによって変わることがあります。- デスクトップでの入力は上の操作に限られます。カメラトラッキング、マイク入力、音声再生、ライティングには対応していません。- デスクトップ版は Cargo でビルドする実行ファイルで、インストーラー、署名済みアプリバンドル、グローバルショートカットはありません。diff --git a/native/README.md b/native/README.mdindex fe0ea7b..226e5ff 100644--- a/native/README.md+++ b/native/README.md@@ -89,10 +89,21 @@ switching avatars; the keyboard controls below continue to work.| Escape or Command + `Q` | Quit |Controls apply while the avatar app has keyboard focus. With click-through on,-mouse events go to the window underneath. Use the Dock or Command-Tab to focus-the avatar app again, then press `C` to turn click-through off. The toggle is not-a global shortcut. If focus cannot be restored, quit from the Dock and relaunch;-click-through always starts off.+mouse events go to the window underneath. On macOS, click the monochrome avatar+icon in the system status bar to open its menu. **Hide Avatar / Show Avatar**+toggles the avatar window; the status icon stays available while it is hidden.+**Click-through** has a checkmark when enabled and can turn click-through off+without focusing the avatar. The `C` key and this checkmark use the same state.++The status menu also has **Open Avatar…**, the same **Open Recent** list as the+app menu, and **Quit Mesh Avatar**. Opening an avatar from this menu first shows+the avatar window, including when the file dialog is cancelled. Hiding keeps the+avatar loaded and pauses rendering. Visibility and click-through are not saved;+the avatar starts visible with click-through off on the next launch.++If the status icon is unavailable, use the Dock or Command-Tab to focus the app,+then press `C`. This is not a global shortcut. If focus cannot be restored, quit+from the Dock and relaunch.Idle movement, blinking, breathing and occasional motions run automatically.Rendering follows the display's presentation rate. Resizing and monitor scale@@ -137,7 +148,7 @@ Metal backend on macOS, and `--dpr=2` checks equal physical sizes at HiDPI.- Windows and Linux desktop behavior has not been verified. Window transparency,always-on-top behavior and cursor click-through depend on the OS compositor.The app exits if a transparent surface is unavailable.-- The native menu bar and Open Avatar dialog are macOS-only. The executable+- The native menu bar, status-bar icon and Open Avatar dialog are macOS-only. The executableembeds the name “Mesh Avatar” without an app bundle; the name shown elsewhereby macOS can depend on how it was launched.- Desktop input is limited to the controls above. Camera tracking, microphonediff --git a/native/README.zh.md b/native/README.zh.mdindex ed38f43..b188642 100644--- a/native/README.zh.md+++ b/native/README.zh.md@@ -72,8 +72,15 @@ native/target/release/mesh-avatar-desktop /path/to/project| Escape 或 Command + `Q` | 退出 |以上操作在虚拟形象程序拥有键盘焦点时有效。开启点击穿透后,鼠标事件会传给下方的窗口。-要关闭点击穿透,请通过 Dock 或 Command-Tab 让虚拟形象程序重新获得焦点,然后按 `C`。该按键不是全局快捷键。-如果无法恢复焦点,请从 Dock 退出后重新启动;点击穿透在启动时总是关闭的。+在 macOS 上,点击系统状态栏中的单色虚拟形象图标即可打开菜单。**Hide Avatar / Show Avatar** 用于隐藏或显示虚拟形象窗口;隐藏后状态图标仍然保留。+启用 **Click-through** 时会显示勾选标记,可在不恢复虚拟形象焦点的情况下关闭点击穿透。`C` 键操作也会同步更新该标记。++状态菜单还提供 **Open Avatar…**、与应用菜单相同的 **Open Recent** 列表,以及 **Quit Mesh Avatar**。+从该菜单打开虚拟形象时,会先显示窗口;取消文件选择后也会保持显示。+隐藏时保留已加载的虚拟形象并暂停渲染。显示状态和点击穿透状态不会保存;下次启动时虚拟形象可见,点击穿透关闭。++如果状态图标不可用,可通过 Dock 或 Command-Tab 恢复应用焦点后按 `C`。该按键不是全局快捷键。+如果无法恢复焦点,请从 Dock 退出后重新启动。待机动作、眨眼、呼吸和不定时的动作会自动播放。渲染频率跟随显示器的刷新节奏。窗口尺寸或显示器缩放比例变化时会更新实际渲染尺寸;在卡顿或从睡眠恢复后,动画的时间步长上限为 0.05 秒。@@ -110,7 +117,7 @@ dump 会检查嵌入的动作数据是否与 JavaScript 源码一致。- 尚未验证 Windows 和 Linux 上的桌面行为。窗口透明、置顶和鼠标点击穿透取决于操作系统的合成器。如果无法使用透明绘制表面,程序会退出。-- 原生菜单栏和 Open Avatar 对话框仅支持 macOS。可执行文件在没有应用包的情况下嵌入了名称“Mesh Avatar”;+- 原生菜单栏、状态栏图标和 Open Avatar 对话框仅支持 macOS。可执行文件在没有应用包的情况下嵌入了名称“Mesh Avatar”;macOS 在其他位置显示的名称可能取决于启动方式。- 桌面端的输入仅限上述操作。不包含摄像头追踪、麦克风输入、音频播放和光照。- 桌面程序是用 Cargo 构建的可执行文件,没有安装程序、已签名的应用包或全局快捷键。diff --git a/native/apps/mesh-avatar-desktop/Cargo.toml b/native/apps/mesh-avatar-desktop/Cargo.tomlindex b666bb1..fa608a4 100644--- a/native/apps/mesh-avatar-desktop/Cargo.toml+++ b/native/apps/mesh-avatar-desktop/Cargo.toml@@ -18,6 +18,7 @@ dirs = "6"[target.'cfg(target_os = "macos")'.dependencies]muda = { version = "0.19.3", default-features = false }+tray-icon = { version = "0.24.2", default-features = false }rfd = { version = "0.17", default-features = false }objc2 = "0.6"objc2-app-kit = { version = "0.3", default-features = false, features = ["std", "NSScreen"] }diff --git a/native/apps/mesh-avatar-desktop/src/main.rs b/native/apps/mesh-avatar-desktop/src/main.rsindex 0ef1d74..9d48221 100644--- a/native/apps/mesh-avatar-desktop/src/main.rs+++ b/native/apps/mesh-avatar-desktop/src/main.rs@@ -6,6 +6,8 @@ mod presentation;mod scaling;mod screens;mod settings;+mod status_bar;+mod window_controls;use anyhow::{bail, ensure, Context, Result};use geometry::{fit_base, switch_layout};use loading::{Loaded, Loader, Recent};@@ -29,6 +31,7 @@ use std::{},time::Instant,};+use window_controls::WindowControls;use winit::{application::ApplicationHandler,dpi::{LogicalPosition, PhysicalPosition, PhysicalSize, Position},@@ -157,7 +160,7 @@ struct Scene {gpu_failed: Arc<AtomicBool>,modifiers: ModifiersState,expression_index: usize,- click_through: bool,+ controls: WindowControls,occluded: bool,}impl Scene {@@ -296,7 +299,7 @@ impl Scene {gpu_failed,modifiers: ModifiersState::empty(),expression_index: 0,- click_through: false,+ controls: WindowControls::default(),occluded: false,})}@@ -406,14 +409,15 @@ impl Scene {self.resize(size)?;}}- if std::mem::take(&mut self.redraw_requested) && !self.occluded {+ self.refresh_visibility();+ if std::mem::take(&mut self.redraw_requested) && self.controls.visible && !self.occluded {self.redraw()?;}ensure!(!self.gpu_failed.load(Ordering::Relaxed),"graphics device reported an error");- if !self.occluded {+ if self.controls.visible && !self.occluded {self.window.request_redraw();}Ok(())@@ -493,13 +497,7 @@ impl Scene {"こんにちは。きょうも、いっしょにあいうえおをれんしゅうしましょう。",SpeakOptions::default(),),- KeyCode::KeyC => match self.window.set_cursor_hittest(self.click_through) {- Ok(()) => {- self.click_through = !self.click_through;- eprintln!("Click-through {}. Focus Mesh Avatar with the Dock or app switcher, then press C to turn it off.",if self.click_through {"on"} else {"off"});- }- Err(error) => eprintln!("Could not change click-through: {error}"),- },+ KeyCode::KeyC => self.toggle_click_through(),KeyCode::Digit1| KeyCode::Digit2| KeyCode::Digit3@@ -534,6 +532,32 @@ impl Scene {eprintln!("Expression: {name}");}}+ fn toggle_click_through(&mut self) {+ let window = &self.window;+ match self.controls.set_click_through(!self.controls.click_through, |enabled|window.set_cursor_hittest(!enabled)) {+ Ok(()) => eprintln!("Click-through {}. Use the Mesh Avatar status-bar icon to turn it off, or focus the app and press C.", if self.controls.click_through {"on"} else {"off"}),+ Err(error) => eprintln!("Could not change click-through: {error}"),+ }+ }+ fn refresh_visibility(&mut self) {+ if let Some(visible) = self.window.is_visible() {+ self.controls.visible = visible;+ }+ }+ fn set_visible(&mut self, visible: bool) {+ if visible {+ self.window.set_minimized(false);+ }+ self.window.set_visible(visible);+ self.controls.visible = visible;+ if visible {+ self.occluded = false;+ self.last_frame = Instant::now();+ self.redraw_requested = true;+ self.window.focus_window();+ self.window.request_redraw();+ }+ }fn placement(&self, include_pending: bool) -> Option<Placement> {if !include_pending&& (self.scaling.has_request()@@ -646,6 +670,9 @@ impl App {}fn service(&mut self, event_loop: &ActiveEventLoop) -> Result<()> {self.observe_settings(Instant::now(), false);+ if let Some(scene) = &mut self.scene {+ scene.refresh_visibility();+ }for command in std::mem::take(&mut self.commands) {match command {menu::Command::Quit => {@@ -653,7 +680,8 @@ impl App {return Ok(());}menu::Command::Open if !self.dialog_open => {- if let Some(scene) = &self.scene {+ if let Some(scene) = &mut self.scene {+ scene.set_visible(true);let directory = if self.current_path.is_dir() {Some(self.current_path.as_path())} else {@@ -666,6 +694,9 @@ impl App {}}menu::Command::Recent(path) => {+ if let Some(scene) = &mut self.scene {+ scene.set_visible(true);+ }self.refresh_recent();self.request_load(path);}@@ -680,6 +711,22 @@ impl App {scene.select_expression(&name);}}+ menu::Command::ToggleVisible => {+ let now = Instant::now();+ self.observe_settings(now, true);+ if let Some(scene) = &mut self.scene {+ scene.set_visible(!scene.controls.visible);+ }+ // Hidden windows stop requesting frames, so finish any pending save now.+ if let Err(error) = self.settings.flush(now, true) {+ eprintln!("Could not save window settings: {error:#}");+ }+ }+ menu::Command::ToggleClickThrough => {+ if let Some(scene) = &mut self.scene {+ scene.toggle_click_through();+ }+ }_ => {}}}@@ -715,6 +762,9 @@ impl App {if let Some(scene) = &mut self.scene {scene.service()?;}+ if let (Some(menu), Some(scene)) = (&mut self.menu, &self.scene) {+ menu.update_controls(scene.controls);+ }let now = Instant::now();self.observe_settings(now, false);if let Err(error) = self.settings.flush(now, false) {diff --git a/native/apps/mesh-avatar-desktop/src/menu.rs b/native/apps/mesh-avatar-desktop/src/menu.rsindex 4b5865e..1febd87 100644--- a/native/apps/mesh-avatar-desktop/src/menu.rs+++ b/native/apps/mesh-avatar-desktop/src/menu.rs@@ -12,6 +12,8 @@ pub enum Command {Quit,Play(String),Expression(String),+ ToggleVisible,+ ToggleClickThrough,}#[cfg(target_os = "macos")]@@ -35,6 +37,7 @@ mod platform {motions: Submenu,expressions: Submenu,avatar_model: AvatarMenu,+ status: Option<crate::status_bar::StatusBar>,}impl AppMenu {pub fn install(proxy: EventLoopProxy<UserEvent>, paths: &[PathBuf]) -> Result<Self> {@@ -85,6 +88,13 @@ mod platform {let expressions = Submenu::new("Expression", true);let avatar = Submenu::with_items("Avatar", true, &[&motions, &expressions])?;root.append_items(&[&app, &file, &avatar, &edit])?;+ let status = match crate::status_bar::StatusBar::new(&recent, &open, &quit) {+ Ok(status) => Some(status),+ Err(error) => {+ eprintln!("Could not create status-bar icon: {error:#}");+ None+ }+ };let mut menu = Self {_root: root,recent,@@ -92,6 +102,7 @@ mod platform {motions,expressions,avatar_model: AvatarMenu::new(&[]),+ status,};menu.set_recent(paths)?;MenuEvent::set_event_handler(Some(move |event: MenuEvent| {@@ -124,6 +135,8 @@ mod platform {"open" => Some(Command::Open),"reload" => Some(Command::Reload),"quit" => Some(Command::Quit),+ "toggle-visible" => Some(Command::ToggleVisible),+ "toggle-click-through" => Some(Command::ToggleClickThrough),_ => self.entries.iter()@@ -153,6 +166,11 @@ mod platform {self.avatar_model = model;Ok(())}+ pub fn update_controls(&mut self, state: crate::window_controls::WindowControls) {+ if let Some(status) = &mut self.status {+ status.update(state);+ }+ }}pub fn open(@@ -212,6 +230,7 @@ mod platform {pub fn set_avatar(&mut self, _: AvatarMenu) -> Result<()> {Ok(())}+ pub fn update_controls(&mut self, _: crate::window_controls::WindowControls) {}}pub fn open(_: EventLoopProxy<UserEvent>, _: &Window, _: Option<&Path>) -> Result<()> {anyhow::bail!("the native Open Avatar dialog is currently available only on macOS")diff --git a/native/apps/mesh-avatar-desktop/src/status_bar.rs b/native/apps/mesh-avatar-desktop/src/status_bar.rsnew file mode 100644index 0000000..602006e--- /dev/null+++ b/native/apps/mesh-avatar-desktop/src/status_bar.rs@@ -0,0 +1,104 @@+//! A small original avatar silhouette, rendered as a macOS template image.+#[cfg(any(target_os = "macos", test))]+fn icon_rgba() -> Vec<u8> {+ let mut rgba = vec![0; 36 * 36 * 4];+ for y in 0..36 {+ for x in 0..36 {+ let dx = x as f64 + 0.5 - 18.0;+ let py = y as f64 + 0.5;+ let head = dx * dx + (py - 11.0).powi(2) <= 7.5_f64.powi(2);+ let shoulders = (23.0..=33.0).contains(&py)+ && (dx / 13.0).powi(2) + ((py - 31.0) / 9.0).powi(2) <= 1.0;+ let eyes = (9.0..=12.0).contains(&py) && (dx.abs() - 3.0).abs() <= 1.0;+ if (head || shoulders) && !eyes {+ rgba[(y * 36 + x) * 4 + 3] = 255;+ }+ }+ }+ rgba+}++#[cfg(target_os = "macos")]+pub struct StatusBar {+ _icon: tray_icon::TrayIcon,+ visibility: muda::MenuItem,+ click_through: muda::CheckMenuItem,+ last_visible: Option<bool>,+}+#[cfg(target_os = "macos")]+impl StatusBar {+ pub fn new(+ recent: &muda::Submenu,+ open: &muda::MenuItem,+ quit: &muda::MenuItem,+ ) -> anyhow::Result<Self> {+ use muda::{CheckMenuItem, Menu, MenuItem, PredefinedMenuItem};+ let menu = Menu::new();+ let visibility = MenuItem::with_id("toggle-visible", "Hide Avatar", true, None);+ let click_through =+ CheckMenuItem::with_id("toggle-click-through", "Click-through", true, false, None);+ menu.append_items(&[+ &visibility,+ &click_through,+ &PredefinedMenuItem::separator(),+ open,+ recent,+ &PredefinedMenuItem::separator(),+ quit,+ ])?;+ let icon = tray_icon::Icon::from_rgba(icon_rgba(), 36, 36)?;+ // Only menu actions are used; avoid retaining unused pointer-move events.+ tray_icon::TrayIconEvent::set_event_handler(Some(|_: tray_icon::TrayIconEvent| {}));+ let icon = tray_icon::TrayIconBuilder::new()+ .with_tooltip("Mesh Avatar")+ .with_icon(icon)+ .with_icon_as_template(true)+ .with_menu(Box::new(menu))+ .with_menu_on_left_click(true)+ .with_menu_on_right_click(true)+ .build()?;+ Ok(Self {+ _icon: icon,+ visibility,+ click_through,+ last_visible: None,+ })+ }+ pub fn update(&mut self, state: crate::window_controls::WindowControls) {+ if self.last_visible != Some(state.visible) {+ self.visibility.set_text(state.visibility_label());+ self.last_visible = Some(state.visible);+ }+ // A native check item toggles before its callback. Restore it if the OS call failed.+ if self.click_through.is_checked() != state.click_through {+ self.click_through.set_checked(state.click_through);+ }+ }+}++#[cfg(test)]+mod tests {+ use super::*;+ #[test]+ fn template_is_nonempty_monochrome_symmetric_and_has_transparent_margin() {+ let pixels = icon_rgba();+ assert_eq!(pixels.len(), 36 * 36 * 4);+ let painted = pixels+ .as_chunks::<4>()+ .0+ .iter()+ .filter(|p| p[3] != 0)+ .count();+ assert!((200..600).contains(&painted));+ for y in 0..36 {+ for x in 0..36 {+ let p = &pixels[(y * 36 + x) * 4..(y * 36 + x) * 4 + 4];+ assert_eq!(&p[..3], &[0, 0, 0]);+ assert_eq!(p[3], pixels[(y * 36 + 35 - x) * 4 + 3]);+ if x == 0 || y == 0 || x == 35 || y == 35 {+ assert_eq!(p[3], 0);+ }+ }+ }+ }+}diff --git a/native/apps/mesh-avatar-desktop/src/window_controls.rs b/native/apps/mesh-avatar-desktop/src/window_controls.rsnew file mode 100644index 0000000..dd07db1--- /dev/null+++ b/native/apps/mesh-avatar-desktop/src/window_controls.rs@@ -0,0 +1,62 @@+//! Shared state for keyboard and status-menu window controls.+#[derive(Clone, Copy, Debug, PartialEq, Eq)]+pub struct WindowControls {+ pub visible: bool,+ pub click_through: bool,+}+impl Default for WindowControls {+ fn default() -> Self {+ Self {+ visible: true,+ click_through: false,+ }+ }+}+impl WindowControls {+ pub fn visibility_label(self) -> &'static str {+ if self.visible {+ "Hide Avatar"+ } else {+ "Show Avatar"+ }+ }+ pub fn set_click_through<E>(+ &mut self,+ enabled: bool,+ apply: impl FnOnce(bool) -> Result<(), E>,+ ) -> Result<(), E> {+ apply(enabled)?;+ self.click_through = enabled;+ Ok(())+ }+}++#[cfg(test)]+mod tests {+ use super::*;+ #[test]+ fn click_through_can_be_recovered_while_hidden_without_changing_visibility() {+ let mut state = WindowControls::default();+ assert_eq!(state.visibility_label(), "Hide Avatar");+ state.set_click_through(true, |_| Ok::<_, ()>(())).unwrap();+ state.visible = false;+ assert_eq!(state.visibility_label(), "Show Avatar");+ state.set_click_through(false, |_| Ok::<_, ()>(())).unwrap();+ assert!(!state.visible && !state.click_through);+ state.visible = true;+ assert_eq!(state, WindowControls::default());+ }+ #[test]+ fn failed_native_toggle_keeps_the_checkmark_state() {+ let mut state = WindowControls::default();+ assert!(state+ .set_click_through(true, |_| Err("unsupported"))+ .is_err());+ assert!(!state.click_through);+ state.set_click_through(true, |_| Ok::<_, ()>(())).unwrap();+ assert!(state+ .set_click_through(false, |_| Err("unsupported"))+ .is_err());+ assert!(state.click_through);+ }+}