mirror of
https://github.com/Drop-OSS/drop
synced 2026-08-27 14:23:05 -04:00
Make an official event
This commit is contained in:
parent
8793680a51
commit
42b662c170
2 changed files with 7 additions and 9 deletions
|
|
@ -42,6 +42,10 @@ listen("update_state", (event) => {
|
|||
state.value = event.payload as AppState;
|
||||
});
|
||||
|
||||
listen("window_visibility_change", () => {
|
||||
document.dispatchEvent(new Event("visibilitychange"));
|
||||
});
|
||||
|
||||
setupHooks();
|
||||
initialNavigation(state);
|
||||
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ use log4rs::{
|
|||
encode::pattern::PatternEncoder,
|
||||
};
|
||||
use tauri::{
|
||||
AppHandle, LogicalPosition, LogicalSize, Manager, RunEvent, WebviewBuilder, WebviewUrl,
|
||||
AppHandle, Emitter, LogicalPosition, LogicalSize, Manager, RunEvent, WebviewBuilder, WebviewUrl,
|
||||
WindowBuilder, WindowEvent,
|
||||
menu::{Menu, MenuItem, PredefinedMenuItem},
|
||||
tray::TrayIconBuilder,
|
||||
|
|
@ -391,11 +391,7 @@ pub fn run() {
|
|||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
// Resume webview rendering after showing
|
||||
if let Some(win) = app.get_window("main") {
|
||||
for wv in win.webviews() {
|
||||
let _ = wv.eval("document.dispatchEvent(new Event('visibilitychange'))");
|
||||
}
|
||||
}
|
||||
app_emit!(app, "window_visibility_change", ());
|
||||
}
|
||||
|
||||
app.get_window("main")
|
||||
|
|
@ -461,9 +457,7 @@ pub fn run() {
|
|||
// Pause webview rendering before hiding to prevent idle CPU usage
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
for wv in window.webviews() {
|
||||
let _ = wv.eval("document.dispatchEvent(new Event('visibilitychange'))");
|
||||
}
|
||||
let _ = window.app_handle().emit("window_visibility_change", ());
|
||||
}
|
||||
|
||||
window.hide().expect("Failed to hide window in tray");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue