Skip to content
Open
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
14 changes: 13 additions & 1 deletion src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use tauri::{App, AppHandle, Emitter, Listener, Manager, State, WebviewUrl, WebviewWindowBuilder};
use tauri::{App, AppHandle, Emitter, Listener, Manager, State, WebviewUrl, WebviewWindowBuilder, WindowEvent};
use tauri_plugin_clipboard_manager::ClipboardExt;
use tauri_plugin_shell::ShellExt;
use tauri_plugin_dialog::DialogExt;
Expand Down Expand Up @@ -841,6 +841,18 @@ pub fn run() {

Ok(())
})
.on_window_event(|window, event| {
// The "main" (preferences) window is a tray app surface: closing it
// should hide it, not destroy it. Destroying leaves get_webview_window
// returning None, so the tray "Open Snipp" item can no longer reopen it
// until the app is restarted.
if window.label() == "main" {
if let WindowEvent::CloseRequested { api, .. } = event {
api.prevent_close();
let _ = window.hide();
}
}
})
.invoke_handler(tauri::generate_handler![
capture_screenshot,
capture_full_screen,
Expand Down