mirror of
https://github.com/Drop-OSS/drop.git
synced 2026-08-24 15:22:05 +10:00
Fixing linux bug where client would never actually quit (#469)
* Fixing linux bug where client would never actually quit * Fixing window minimizing to tray * Make an official event --------- Co-authored-by: Robert Clabough <robert@clabough.tech>
This commit is contained in:
co-authored by
Robert Clabough
parent
380e3a50b4
commit
12c81eb1ac
@@ -42,6 +42,10 @@ listen("update_state", (event) => {
|
|||||||
state.value = event.payload as AppState;
|
state.value = event.payload as AppState;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
listen("window_visibility_change", () => {
|
||||||
|
document.dispatchEvent(new Event("visibilitychange"));
|
||||||
|
});
|
||||||
|
|
||||||
setupHooks();
|
setupHooks();
|
||||||
initialNavigation(state);
|
initialNavigation(state);
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ use log4rs::{
|
|||||||
encode::pattern::PatternEncoder,
|
encode::pattern::PatternEncoder,
|
||||||
};
|
};
|
||||||
use tauri::{
|
use tauri::{
|
||||||
AppHandle, LogicalPosition, LogicalSize, Manager, RunEvent, WebviewBuilder, WebviewUrl,
|
AppHandle, Emitter, LogicalPosition, LogicalSize, Manager, RunEvent, WebviewBuilder, WebviewUrl,
|
||||||
WindowBuilder, WindowEvent,
|
WindowBuilder, WindowEvent,
|
||||||
menu::{Menu, MenuItem, PredefinedMenuItem},
|
menu::{Menu, MenuItem, PredefinedMenuItem},
|
||||||
tray::TrayIconBuilder,
|
tray::TrayIconBuilder,
|
||||||
@@ -388,9 +388,14 @@ pub fn run() {
|
|||||||
.menu(&menu)
|
.menu(&menu)
|
||||||
.on_menu_event(|app, event| match event.id.as_ref() {
|
.on_menu_event(|app, event| match event.id.as_ref() {
|
||||||
"open" => {
|
"open" => {
|
||||||
app.webview_windows()
|
#[cfg(target_os = "linux")]
|
||||||
.get("frontend")
|
{
|
||||||
.expect("Failed to get webview")
|
// Resume webview rendering after showing
|
||||||
|
app_emit!(app, "window_visibility_change", ());
|
||||||
|
}
|
||||||
|
|
||||||
|
app.get_window("main")
|
||||||
|
.expect("Failed to get main window")
|
||||||
.show()
|
.show()
|
||||||
.expect("Failed to show window");
|
.expect("Failed to show window");
|
||||||
}
|
}
|
||||||
@@ -449,7 +454,13 @@ pub fn run() {
|
|||||||
.on_window_event(|window, event| {
|
.on_window_event(|window, event| {
|
||||||
if let WindowEvent::CloseRequested { api, .. } = event {
|
if let WindowEvent::CloseRequested { api, .. } = event {
|
||||||
run_on_tray(|| {
|
run_on_tray(|| {
|
||||||
window.hide().expect("Failed to close window in tray");
|
// Pause webview rendering before hiding to prevent idle CPU usage
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
{
|
||||||
|
let _ = window.app_handle().emit("window_visibility_change", ());
|
||||||
|
}
|
||||||
|
|
||||||
|
window.hide().expect("Failed to hide window in tray");
|
||||||
api.prevent_close();
|
api.prevent_close();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -458,7 +469,12 @@ pub fn run() {
|
|||||||
.expect("error while running tauri application");
|
.expect("error while running tauri application");
|
||||||
|
|
||||||
app.run(|_app_handle, event| {
|
app.run(|_app_handle, event| {
|
||||||
if let RunEvent::ExitRequested { code, api, .. } = event {
|
if let RunEvent::ExitRequested {
|
||||||
|
code,
|
||||||
|
api,
|
||||||
|
..
|
||||||
|
} = event
|
||||||
|
{
|
||||||
run_on_tray(|| {
|
run_on_tray(|| {
|
||||||
if code.is_none() {
|
if code.is_none() {
|
||||||
api.prevent_exit();
|
api.prevent_exit();
|
||||||
|
|||||||
Reference in New Issue
Block a user