docs(plan): add set_window_opacity Rust command

Tauri 2 JS WebviewWindow does not expose setOpacity (only the Rust
side has set_opacity), so the JS layer routes through a custom
command. Surfaced during Task 9 implementation; updates Tasks 16 and
17 to register the command.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Michael Chihlas
2026-05-08 17:55:25 -04:00
parent 2269e443b8
commit a91be65354

View File

@@ -1881,6 +1881,20 @@ pub fn get_hotkey_status(app: AppHandle) -> Result<crate::HotkeyStatus, String>
let guard = state.hotkey_status.lock().map_err(|_| "poisoned".to_string())?; let guard = state.hotkey_status.lock().map_err(|_| "poisoned".to_string())?;
Ok(guard.clone()) Ok(guard.clone())
} }
/// Set window opacity. Tauri 2's JS WebviewWindow does NOT expose setOpacity
/// (only the Rust side does), so the JS layer routes through this command.
#[tauri::command]
pub fn set_window_opacity<R: Runtime>(
app: AppHandle<R>,
label: String,
opacity: f32,
) -> Result<(), String> {
let Some(window) = app.get_webview_window(&label) else {
return Err(format!("window not found: {label}"));
};
window.set_opacity(opacity).map_err(|e| e.to_string())
}
``` ```
> **Note on the design:** Tauri 2 doesn't expose a getter for `ignore_cursor_events` / `opacity` on `WebviewWindow`. Rather than rely on getters, we keep a tiny Rust-side cache (`AppState.click_through`) that the JS side keeps in sync via `sync_click_through_cache`. The global shortcut handler reads this cache, computes the inverse, calls `apply_state`. The JS-driven toggle path uses `toggle_click_through(current)` and skips the cache. > **Note on the design:** Tauri 2 doesn't expose a getter for `ignore_cursor_events` / `opacity` on `WebviewWindow`. Rather than rely on getters, we keep a tiny Rust-side cache (`AppState.click_through`) that the JS side keeps in sync via `sync_click_through_cache`. The global shortcut handler reads this cache, computes the inverse, calls `apply_state`. The JS-driven toggle path uses `toggle_click_through(current)` and skips the cache.
@@ -1994,6 +2008,7 @@ pub fn run() {
commands::overlay::toggle_click_through, commands::overlay::toggle_click_through,
commands::overlay::sync_click_through_cache, commands::overlay::sync_click_through_cache,
commands::overlay::get_hotkey_status, commands::overlay::get_hotkey_status,
commands::overlay::set_window_opacity,
]) ])
.run(tauri::generate_context!()) .run(tauri::generate_context!())
.expect("error while running tauri application"); .expect("error while running tauri application");