()
| 66 | |
| 67 | #[cfg_attr(mobile, tauri::mobile_entry_point)] |
| 68 | pub fn run() { |
| 69 | let builder = tauri::Builder::default() |
| 70 | .plugin(tauri_plugin_single_instance::init(|app, argv, _cwd| { |
| 71 | // Focus the existing window when a duplicate instance launches. |
| 72 | if let Some(w) = app.get_webview_window("main") { |
| 73 | let _ = w.set_focus(); |
| 74 | } |
| 75 | // Forward any deep link URLs from the duplicate launch. |
| 76 | for arg in &argv { |
| 77 | if arg.starts_with("buzz://") { |
| 78 | handle_deep_link_url(app, arg); |
| 79 | } |
| 80 | } |
| 81 | })) |
| 82 | .plugin(tauri_plugin_deep_link::init()) |
| 83 | .plugin(tauri_plugin_notification::init()) |
| 84 | .plugin(tauri_plugin_opener::init()) |
| 85 | .plugin( |
| 86 | tauri_plugin_window_state::Builder::default() |
| 87 | // The main window should always launch edge-to-edge in the |
| 88 | // available desktop area. Do not let stale saved geometry or |
| 89 | // fullscreen state override the maximized launch config. |
| 90 | .with_state_flags( |
| 91 | StateFlags::all() |
| 92 | & !(StateFlags::VISIBLE |
| 93 | | StateFlags::POSITION |
| 94 | | StateFlags::SIZE |
| 95 | | StateFlags::MAXIMIZED |
| 96 | | StateFlags::FULLSCREEN), |
| 97 | ) |
| 98 | .build(), |
| 99 | ) |
| 100 | .plugin(tauri_plugin_websocket::init()) |
| 101 | .plugin(tauri_plugin_dialog::init()) |
| 102 | .plugin(tauri_plugin_process::init()); |
| 103 | |
| 104 | // The global-shortcut plugin is omitted from test builds: linking it into |
| 105 | // the lib-test binary makes it fail to load on Windows |
| 106 | // (STATUS_ENTRYPOINT_NOT_FOUND) before any test runs. |
| 107 | #[cfg(not(test))] |
| 108 | let builder = builder.plugin({ |
| 109 | use tauri_plugin_global_shortcut::ShortcutState; |
| 110 | |
| 111 | // Generation counter for the release delay task. Incremented on |
| 112 | // every press — a delayed release only fires if the generation |
| 113 | // hasn't changed (i.e. no new press happened during the delay). |
| 114 | // This prevents press→release→press within 200 ms from having |
| 115 | // the first release clobber the second press. |
| 116 | let ptt_press_gen = Arc::new(std::sync::atomic::AtomicU64::new(0)); |
| 117 | |
| 118 | tauri_plugin_global_shortcut::Builder::new() |
| 119 | .with_handler(move |app, _shortcut, event| { |
| 120 | let state = match app.try_state::<AppState>() { |
| 121 | Some(s) => s, |
| 122 | None => return, |
| 123 | }; |
| 124 | |
| 125 | // Only act if a huddle is active and mode is PTT. |
no test coverage detected