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
24 changes: 17 additions & 7 deletions desktop/src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -446,22 +446,32 @@ pub fn run() {
handle_server_proto_wrapper(request, responder).await;
});
})
.on_window_event(|window, event| {
if let WindowEvent::CloseRequested { api, .. } = event {
.on_window_event(|_window, event| {
if let WindowEvent::CloseRequested { api: _api, .. } = event {
// On Linux, hiding the window keeps WebkitGTK rendering in the
// background which causes 100% CPU usage. Let the app exit instead.
#[cfg(not(target_os = "linux"))]
run_on_tray(|| {
window.hide().expect("Failed to close window in tray");
api.prevent_close();
_window.hide().expect("Failed to close window in tray");
_api.prevent_close();
});
}
})
.build(tauri::generate_context!())
.expect("error while running tauri application");

app.run(|_app_handle, event| {
if let RunEvent::ExitRequested { code, api, .. } = event {
if let RunEvent::ExitRequested {
code: _code,
api: _api,
..
} = event
{
// On Linux, let the app exit cleanly (see on_window_event above).
#[cfg(not(target_os = "linux"))]
run_on_tray(|| {
if code.is_none() {
api.prevent_exit();
if _code.is_none() {
_api.prevent_exit();
}
});
}
Expand Down