feat(native): Tier A desktop features (P5-46/36/44/43/49) + window chrome (P5-47)

Adds a `native/` module system (each feature = its own module exposing
`#[tauri::command]`s + optional `setup`; `emit_to_web` pushes DOM CustomEvents to
the web like `forward_deeplink`). Wired into generate_handler! + native::setup;
windows-crate feature union added to Cargo.toml.

- power.rs (P5-46): SetThreadExecutionState held on the main thread while a call
  is active; released on end. Cross-platform (no-op off Windows).
- jumplist.rs (P5-36): ICustomDestinationList "Recent Rooms" of IShellLink tasks
  launching the exe with a matrix: arg (existing deep-link handler opens the room).
- thumbbar.rs (P5-44): ITaskbarList3 ThumbBar Mute/Deafen/End (GDI HICONs) + a
  window subclass catching THBN_CLICKED → emit thumbbar-action.
- smtc.rs (P5-43): WinRT SystemMediaTransportControls via GetForWindow; ButtonPressed
  → smtc-action; call-state command. (Experimental for a non-media app.)
- network.rs (P5-49): INetworkListManager poll thread → emit network-changed.
- chrome.rs (P5-47): cross-platform window-control commands + set_custom_chrome
  (set_decorations) for the opt-in TDS titlebar.

NOT compile-verified locally (no Rust/Windows toolchain on the dev box) — this is
for the CI Windows compile pass (GitHub test.yml / Gitea windows runner). Expect a
possible fixup round (windows-crate feature/namespace paths, e.g. subclass APIs).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-01 11:04:24 -04:00
co-authored by Claude Opus 4.8
parent eeb842c7b1
commit 73d15b13d2
9 changed files with 999 additions and 0 deletions
+68
View File
@@ -0,0 +1,68 @@
//! P5-47 — TDS Custom Window Chrome (opt-in, runtime-reversible).
//!
//! When the user opts into custom window chrome, the web client renders its own
//! `<TitleBar/>` (folds/TDS styled) and we strip the OS-native window frame so
//! the two don't stack. This is entirely opt-in: the window is built with native
//! `decorations(true)` and only `set_custom_chrome(true)` makes it frameless, so
//! the safe default is the untouched native frame.
//!
//! Everything here goes through the cross-platform Tauri v2 window API — there is
//! no `windows` crate dependency, so the same code path runs on Windows, macOS
//! and Linux. Each command resolves the "main" window and silently no-ops if it
//! isn't present (e.g. during teardown); the `Result`s are intentionally ignored
//! since a failed chrome tweak should never surface as an error to the user.
use tauri::{AppHandle, Manager};
/// Toggle the native window frame. `enabled` = custom chrome on, which means the
/// OS decorations must come **off** (`set_decorations(!enabled)`). Passing
/// `false` restores the native frame, making the feature fully reversible at
/// runtime without a restart.
#[tauri::command]
pub fn set_custom_chrome(app: AppHandle, enabled: bool) {
if let Some(window) = app.get_webview_window("main") {
let _ = window.set_decorations(!enabled);
}
}
/// Minimize the main window (custom titlebar min button).
#[tauri::command]
pub fn window_minimize(app: AppHandle) {
if let Some(window) = app.get_webview_window("main") {
let _ = window.minimize();
}
}
/// Toggle maximize/restore the main window (custom titlebar max button and
/// drag-region double-click).
#[tauri::command]
pub fn window_toggle_maximize(app: AppHandle) {
if let Some(window) = app.get_webview_window("main") {
if window.is_maximized().unwrap_or(false) {
let _ = window.unmaximize();
} else {
let _ = window.maximize();
}
}
}
/// Begin an OS-level window drag from the custom titlebar drag region. The web
/// side also marks the drag area with `data-tauri-drag-region`; this command is
/// the explicit fallback so behaviour is identical across platforms.
#[tauri::command]
pub fn window_start_drag(app: AppHandle) {
if let Some(window) = app.get_webview_window("main") {
let _ = window.start_dragging();
}
}
/// Close from the custom titlebar. Mirrors the app's close-to-tray behaviour
/// (see the `CloseRequested` handler in `lib.rs`): we `hide()` the window rather
/// than exiting, so the tray keeps the app running and the tray menu remains the
/// single explicit quit path.
#[tauri::command]
pub fn window_close(app: AppHandle) {
if let Some(window) = app.get_webview_window("main") {
let _ = window.hide();
}
}