-
-
Notifications
You must be signed in to change notification settings - Fork 353
feat: hide main window on Cmd+W and restore on reopen #241
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
2f279ab
e4a038b
dad99b1
ce2a0f8
f8fe26a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| use tauri::Manager; | ||
| use tauri::{Manager, RunEvent, WindowEvent}; | ||
|
|
||
| mod backend; | ||
| mod codex; | ||
|
|
@@ -42,6 +42,16 @@ pub fn run() { | |
| .manage(menu::MenuItemRegistry::<tauri::Wry>::default()) | ||
| .menu(menu::build_menu) | ||
| .on_menu_event(menu::handle_menu_event) | ||
| .on_window_event(|window, event| { | ||
| if window.label() != "main" { | ||
| return; | ||
| } | ||
| #[cfg(target_os = "macos")] | ||
| if let WindowEvent::CloseRequested { api, .. } = event { | ||
| api.prevent_close(); | ||
| let _ = window.hide(); | ||
| } | ||
| }) | ||
| .setup(|app| { | ||
| let state = state::AppState::load(&app.handle()); | ||
| app.manage(state); | ||
|
|
@@ -56,7 +66,7 @@ pub fn run() { | |
| #[cfg(desktop)] | ||
| let builder = builder.plugin(tauri_plugin_window_state::Builder::default().build()); | ||
|
|
||
| builder | ||
| let app = builder | ||
| .plugin(tauri_plugin_liquid_glass::init()) | ||
| .plugin(tauri_plugin_opener::init()) | ||
| .plugin(tauri_plugin_dialog::init()) | ||
|
|
@@ -143,6 +153,15 @@ pub fn run() { | |
| dictation::dictation_cancel, | ||
| local_usage::local_usage_snapshot | ||
| ]) | ||
| .run(tauri::generate_context!()) | ||
| .build(tauri::generate_context!()) | ||
| .expect("error while running tauri application"); | ||
|
|
||
| app.run(|app_handle, event| { | ||
| if let RunEvent::Reopen { .. } = event { | ||
| if let Some(window) = app_handle.get_webview_window("main") { | ||
| let _ = window.show(); | ||
| let _ = window.set_focus(); | ||
|
Comment on lines
+159
to
+163
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
On Linux/Windows builds, Useful? React with 👍 / 👎. |
||
| } | ||
| } | ||
| }); | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.