Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Commit

Permalink
app: clicking on dock icon should open main window (#53793)
Browse files Browse the repository at this point in the history
Closes https://github.com/sourcegraph/sourcegraph/issues/53756

This allows clicking the dock icon to show the main window if it is
closed but the app is still running.

This is a temporary solution that only works if the app has a single
window. If we need to add more windows in the future, we need to wait
until tauri-apps/tauri#3084 is fixed.

## Test plan

1. Open app
2. Close with red button on top-left of window
3. Click on Cody icon in dock

App main window should be shown again.
  • Loading branch information
limitedmage authored and ErikaRS committed Jun 22, 2023
1 parent 03b4988 commit b228885
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,12 @@ fn main() {
tauri::WindowEvent::CloseRequested { api, .. } => {
// Ensure the app stays open after the last window is closed.
if event.window().label() == "main" {
event.window().hide().unwrap();
// We use `tauri::AppHandle::hide` instead of `event.window().hide` because
// hiding the app allows clicking the dock icon to show the app again.
// This is a temporary solution that only works if the app has a single window.
// If we need to add more windows in the future, we need to wait until
// https://github.com/tauri-apps/tauri/issues/3084 is fixed.
tauri::AppHandle::hide(&event.window().app_handle()).unwrap();
api.prevent_close();
}
}
Expand Down

0 comments on commit b228885

Please sign in to comment.