Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tauri-app/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ windows = { version = "0.58", features = [
"Win32_Security",
"Win32_System_Pipes",
"Win32_System_IO",
"Win32_System_Com",
"Win32_System_Threading",
"Win32_System_Diagnostics_ToolHelp",
"Win32_UI_Shell",
Expand Down
36 changes: 35 additions & 1 deletion tauri-app/src-tauri/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,46 @@ pub fn get_settings(settings_mgr: State<'_, SettingsManager>) -> OverlaySettings
settings_mgr.get_settings()
}

#[tauri::command]
pub fn take_pending_overlay_launch(app: AppHandle) -> bool {
let state = app.state::<crate::shortcuts::OverlayLaunchRequests>();
let mut requests = state.0.lock().unwrap();
requests.ready()
}

#[tauri::command]
pub fn configure_launch_hotkey(enabled: bool, accelerator: String, settings_mgr: State<'_, SettingsManager>, app: AppHandle) -> Result<OverlaySettings, String> {
let mut settings = settings_mgr.get_settings();
if enabled {
crate::launch_hotkey::shell_hotkey(&accelerator)?;
if accelerator == settings.recording_shortcut { return Err("This shortcut is already used for recording.".into()); }
}
crate::shortcuts::apply(&app, crate::shortcuts::ShortcutAction::ToggleOverlay, "")?;
if let Err(error) = crate::launch_hotkey::sync(if enabled { Some(&accelerator) } else { None }) {
crate::shortcuts::apply_all(&app, &settings);
return Err(error);
}
settings.launch_with_hotkey = enabled;
settings.overlay_shortcut = accelerator;
settings_mgr.save_settings(settings.clone());
crate::shortcuts::apply_all(&app, &settings);
let _ = app.emit("settings-changed", &settings);
Ok(settings)
}

#[tauri::command]
pub fn save_settings(
settings: OverlaySettings,
mut settings: OverlaySettings,
settings_mgr: State<'_, SettingsManager>,
app: AppHandle,
) {
// Launch ownership changes only through configure_launch_hotkey. A delayed
// full-settings save from the other webview must not undo that transaction.
let current = settings_mgr.get_settings();
settings.launch_with_hotkey = current.launch_with_hotkey;
if current.launch_with_hotkey {
settings.overlay_shortcut = current.overlay_shortcut;
}
settings_mgr.save_settings(settings.clone());
// Re-register the global shortcuts from whatever was just saved.
//
Expand Down
Loading
Loading