Fixes three interlocking concurrency leaks in the evdev hotkey listener flagged by the atomiser full-sweep. Every spawned task is now owned by a SupervisorHandle that broadcasts cooperative shutdown and joins every JoinHandle with a 2s per-task timeout on stop(). Per-device attachment is now insert-before-spawn under one mutex hold, closing the TOCTOU window. The Tauri command layer now stores the forwarder JoinHandle alongside the listener so reconfigures join it cleanly instead of leaking one permanent forwarder per hotkey change. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
38 lines
1.2 KiB
Rust
38 lines
1.2 KiB
Rust
//! No-op stub for non-Linux platforms.
|
|
//!
|
|
//! On macOS and Windows, Tauri's global-shortcut plugin handles hotkeys
|
|
//! natively. This stub exists so the crate compiles on all platforms.
|
|
//!
|
|
//! The signature here mirrors the Linux backend so the consumer (the
|
|
//! Tauri command layer) can use the same call shape on every platform:
|
|
//! `EvdevHotkeyListener::start(...).await` and `listener.stop().await`.
|
|
|
|
use tokio::sync::mpsc;
|
|
|
|
use crate::HotkeyCombo;
|
|
|
|
/// Events emitted by the hotkey listener.
|
|
#[derive(Debug, Clone)]
|
|
pub enum HotkeyEvent {
|
|
Pressed,
|
|
Released,
|
|
}
|
|
|
|
/// Stub listener that does nothing on non-Linux platforms.
|
|
pub struct EvdevHotkeyListener;
|
|
|
|
impl EvdevHotkeyListener {
|
|
/// Mirrors the Linux backend's async constructor so consumers can
|
|
/// `await` the same call shape regardless of platform.
|
|
pub async fn start(_combo: HotkeyCombo, _event_tx: mpsc::Sender<HotkeyEvent>) -> Self {
|
|
tracing::info!("evdev hotkey listener is a no-op on this platform");
|
|
Self
|
|
}
|
|
|
|
pub fn set_hotkey(&self, _combo: HotkeyCombo) {}
|
|
|
|
/// Consuming stop mirrors the Linux backend so callers can rely on
|
|
/// the listener being unusable after shutdown on every platform.
|
|
pub async fn stop(self) {}
|
|
}
|