From bdf0d18c926f4bac995f242b904ee8d2664313f0 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Mon, 16 Sep 2024 15:08:33 +0200 Subject: [PATCH] Listen for `visibilitychange` event --- crates/eframe/src/web/events.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/eframe/src/web/events.rs b/crates/eframe/src/web/events.rs index f369ea8aa0b..cdecf3b701e 100644 --- a/crates/eframe/src/web/events.rs +++ b/crates/eframe/src/web/events.rs @@ -107,7 +107,7 @@ pub(crate) fn install_event_handlers(runner_ref: &WebRunner) -> Result<(), JsVal fn install_blur_focus(runner_ref: &WebRunner, target: &EventTarget) -> Result<(), JsValue> { // NOTE: because of the text agent we sometime miss 'blur' events, // so we also poll the focus state each frame in `AppRunner::logic`. - for event_name in ["blur", "focus"] { + for event_name in ["blur", "focus", "visibilitychange"] { let closure = move |_event: web_sys::MouseEvent, runner: &mut AppRunner| { log::trace!("{} {event_name:?}", runner.canvas().id()); runner.update_focus();