diff --git a/app.vue b/app.vue index 560c294..bf26ac9 100644 --- a/app.vue +++ b/app.vue @@ -248,7 +248,6 @@ onMounted(async () => { } }); - await listen('tauri://blur', hideApp); await listen('tauri://focus', focusSearchInput); focusSearchInput(); @@ -262,7 +261,7 @@ onMounted(async () => { const hideApp = async () => { await app.hide(); - await window.getCurrent().hide(); + await window.getCurrentWindow().hide(); }; const showApp = async () => { diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index cebe294..6a1c6e4 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -3240,7 +3240,6 @@ dependencies = [ "tauri-plugin-global-shortcut", "tauri-plugin-os", "tauri-plugin-sql", - "tauri-plugin-window-state", "tokio", "url", ] @@ -4744,21 +4743,6 @@ dependencies = [ "tokio", ] -[[package]] -name = "tauri-plugin-window-state" -version = "2.0.0-beta.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbfc2be8b130fcba31930e862aa04cce60676a60417d76759a0607c917825a06" -dependencies = [ - "bitflags 2.6.0", - "log", - "serde", - "serde_json", - "tauri", - "tauri-plugin", - "thiserror", -] - [[package]] name = "tauri-runtime" version = "2.0.0-beta.19" diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index fd6f731..1780d50 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -11,7 +11,6 @@ tauri-build = { version = "2.0.0-beta.18", features = [] } [dependencies] tauri = { version = "2.0.0-beta.23", features = ["unstable", "tray-icon", "image-png"] } -tauri-plugin-window-state = "2.0.0-beta.10" tauri-plugin-sql = {version = "2.0.0-beta.8", features = ["sqlite"] } tauri-plugin-clipboard-manager = "2.1.0-beta.5" tauri-plugin-global-shortcut = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2" } diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 4321e6d..d869adf 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -11,7 +11,6 @@ mod tray; use tauri::Manager; use tauri::PhysicalPosition; use tauri_plugin_autostart::MacosLauncher; -use tauri_plugin_window_state::{AppHandleExt, StateFlags, WindowExt}; fn center_window_on_current_monitor(window: &tauri::Window) { if let Some(monitor) = window.current_monitor().unwrap() { @@ -33,7 +32,6 @@ fn main() { .plugin(tauri_plugin_clipboard_manager::init()) .plugin(tauri_plugin_os::init()) .plugin(tauri_plugin_global_shortcut::Builder::new().build()) - .plugin(tauri_plugin_window_state::Builder::default().build()) .plugin(tauri_plugin_sql::Builder::default().build()) .plugin(tauri_plugin_autostart::init( MacosLauncher::LaunchAgent, @@ -48,34 +46,32 @@ fn main() { clipboard::setup(app_handle); if let Some(window) = app.get_window("main") { - let _ = window.restore_state(StateFlags::POSITION); center_window_on_current_monitor(&window); window.hide().unwrap(); } - // #[cfg(dev)] - // { - // let window = app.get_webview_window("main").unwrap(); - // window.open_devtools(); - // window.close_devtools(); - // } + #[cfg(dev)] + { + let window = app.get_webview_window("main").unwrap(); + window.open_devtools(); + window.close_devtools(); + } Ok(()) }) .on_window_event(|app, event| match event { - tauri::WindowEvent::CloseRequested { .. } - | tauri::WindowEvent::Destroyed - | tauri::WindowEvent::Focused(false) => { - let _ = AppHandleExt::save_window_state(app.app_handle(), StateFlags::POSITION); + tauri::WindowEvent::Focused(false) => { + println!("Window lost focus"); + if let Some(window) = app.get_window("main") { + window.hide().unwrap(); + } } tauri::WindowEvent::Focused(true) => { - if let Some(window) = app.get_window("main") { - center_window_on_current_monitor(&window); - } + println!("Window gained focus"); } _ => {} }) .invoke_handler(tauri::generate_handler![clipboard::simulate_paste]) .run(tauri::generate_context!()) .expect("error while running tauri application"); -} +} \ No newline at end of file