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:
@@ -0,0 +1,48 @@
|
||||
//! P5-46 — System power management (call continuity).
|
||||
//!
|
||||
//! Prevents the system from sleeping / turning off the display while a voice or
|
||||
//! video call is active, then releases the request when the call ends. The web
|
||||
//! client calls `set_call_active(true|false)` from `useTauriCallPower` as the
|
||||
//! call-embed atom transitions.
|
||||
//!
|
||||
//! Windows: `SetThreadExecutionState`. The request is per-thread and persists
|
||||
//! until cleared, so we run every set/clear on the **main thread** (via
|
||||
//! `run_on_main_thread`) to guarantee the clear cancels the matching set even
|
||||
//! though Tauri commands otherwise run on a pool thread.
|
||||
//!
|
||||
//! Other platforms are a no-op for now (macOS would use `IOPMAssertionCreate`,
|
||||
//! Linux `org.freedesktop.ScreenSaver`/`login1` inhibit) — tracked as a future
|
||||
//! extension; the command stays cross-platform so the web side is unconditional.
|
||||
|
||||
use tauri::AppHandle;
|
||||
|
||||
#[tauri::command]
|
||||
pub fn set_call_active(app: AppHandle, active: bool) {
|
||||
#[cfg(target_os = "windows")]
|
||||
{
|
||||
let _ = app.run_on_main_thread(move || {
|
||||
use windows::Win32::System::Power::{
|
||||
SetThreadExecutionState, ES_CONTINUOUS, ES_DISPLAY_REQUIRED, ES_SYSTEM_REQUIRED,
|
||||
};
|
||||
let flags = if active {
|
||||
ES_CONTINUOUS | ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED
|
||||
} else {
|
||||
// Clearing to ES_CONTINUOUS alone releases the sleep/display
|
||||
// requirement while leaving no lingering per-thread state.
|
||||
ES_CONTINUOUS
|
||||
};
|
||||
// Safety: FFI call with no pointers; returns the previous state,
|
||||
// which we don't need.
|
||||
unsafe {
|
||||
SetThreadExecutionState(flags);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
{
|
||||
// No-op on non-Windows platforms (see module docs). Bind the args so the
|
||||
// signature stays identical cross-platform and no unused warnings fire.
|
||||
let _ = (&app, active);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user