Skip to content

armgit / Handy

Public Imported from GitHub
0

A free, open source, and extensible speech-to-text application that works completely offline.

make sure to focus window when clicking 'check for updates'

CJ Pais085543d6f34e
diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs
index f35ed523..414062f7 100644
--- a/src-tauri/src/lib.rs
+++ b/src-tauri/src/lib.rs
@@ -26,6 +26,28 @@ struct ShortcutToggleStates {
type ManagedToggleState = Mutex<ShortcutToggleStates>;
+fn show_main_window(app: &AppHandle) {
+ if let Some(main_window) = app.get_webview_window("main") {
+ // First, ensure the window is visible
+ if let Err(e) = main_window.show() {
+ eprintln!("Failed to show window: {}", e);
+ }
+ // Then, bring it to the front and give it focus
+ if let Err(e) = main_window.set_focus() {
+ eprintln!("Failed to focus window: {}", e);
+ }
+ // Optional: On macOS, ensure the app becomes active if it was an accessory
+ #[cfg(target_os = "macos")]
+ {
+ if let Err(e) = app.set_activation_policy(tauri::ActivationPolicy::Regular) {
+ eprintln!("Failed to set activation policy to Regular: {}", e);
+ }
+ }
+ } else {
+ eprintln!("Main window not found");
+ }
+}
+
#[tauri::command]
fn trigger_update_check(app: AppHandle) -> Result<(), String> {
app.emit("check-for-updates", ())
@@ -98,29 +120,10 @@ pub fn run() {
.icon_as_template(true)
.on_menu_event(|app, event| match event.id.as_ref() {
"settings" => {
- if let Some(settings_window) = app.get_webview_window("main") {
- // First, ensure the window is visible
- if let Err(e) = settings_window.show() {
- eprintln!("Failed to show window: {}", e);
- }
- // Then, bring it to the front and give it focus
- if let Err(e) = settings_window.set_focus() {
- eprintln!("Failed to focus window: {}", e);
- }
- // Optional: On macOS, ensure the app becomes active if it was an accessory
- #[cfg(target_os = "macos")]
- {
- if let Err(e) =
- app.set_activation_policy(tauri::ActivationPolicy::Regular)
- {
- eprintln!("Failed to set activation policy to Regular: {}", e);
- }
- }
- } else {
- eprintln!("Main window not found");
- }
+ show_main_window(app);
}
"check_updates" => {
+ show_main_window(app);
let _ = app.emit("check-for-updates", ());
}
"quit" => {