diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 572eec1c..5be03323 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -121,7 +121,15 @@ mod setup; #[tauri::command] async fn show_window(window: tauri::Window) { - window.show().unwrap(); + let _ = window.show(); + let _ = window.unminimize(); + let _ = window.set_focus(); +} + +fn bring_webview_window_to_front(window: &tauri::WebviewWindow) { + let _ = window.show(); + let _ = window.unminimize(); + let _ = window.set_focus(); } fn process_internal_embeds(content: &str) -> Cow<'_, str> { @@ -632,6 +640,9 @@ fn clipboard_read_text() -> Result { #[tauri::command] fn clipboard_read_image(macos_image_scaling: bool) -> Result { + #[cfg(not(target_os = "macos"))] + let _ = macos_image_scaling; + let mut clipboard = arboard::Clipboard::new().map_err(|e| e.to_string())?; let image = clipboard.get_image().map_err(|e| e.to_string())?; @@ -860,6 +871,9 @@ pub fn run() { .plugin(tauri_plugin_dialog::init()) .plugin(tauri_plugin_single_instance::init(|app, args, cwd| { println!("Single Instance Args: {:?}", args); + let Some(window) = app.get_webview_window("main") else { + return; + }; let path_str = args .iter() @@ -877,15 +891,9 @@ pub fn run() { cwd_path.join(path).display().to_string() }; - let _ = app - .get_webview_window("main") - .expect("no main window") - .emit("file-path", resolved_path); + let _ = window.emit("file-path", resolved_path); } - let _ = app - .get_webview_window("main") - .expect("no main window") - .set_focus(); + bring_webview_window_to_front(&window); })) .plugin(tauri_plugin_prevent_default::init()) .plugin(tauri_plugin_updater::Builder::new().build()) @@ -1080,6 +1088,7 @@ pub fn run() { if let Some(path) = file_path { let _ = window.emit("file-path", path.as_str()); + bring_webview_window_to_front(&window); } // If installer, force size (this will be saved to installer-state, not main-state) @@ -1166,7 +1175,7 @@ pub fn run() { if let Some(window) = _app_handle.get_webview_window("main") { let _ = window.emit("file-path", path_str); - let _ = window.set_focus(); + bring_webview_window_to_front(&window); } } }