1
0
mirror of https://github.com/emilk/egui.git synced 2026-09-02 14:50:03 -04:00

Call logic even while browser tab is in background (#8257)

* Closes https://github.com/emilk/egui/issues/5112

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Lucas Meurer
2026-06-25 14:59:45 +02:00
committed by GitHub
parent 26ead4af21
commit 2e26b70ae9
10 changed files with 277 additions and 14 deletions

View File

@@ -28,6 +28,10 @@ impl DemoApp for DemoWindows {
fn demo_ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame) {
self.ui(ui);
}
fn logic(&mut self, ctx: &egui::Context) {
self.logic(ctx);
}
}
// ----------------------------------------------------------------------------
@@ -280,6 +284,14 @@ impl eframe::App for WrapApp {
color.to_normalized_gamma_f32()
}
fn logic(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
// Run background logic for every app, even the ones not currently shown,
// so they keep working while the app is hidden (e.g. a backgrounded tab).
for (_name, _anchor, app) in self.apps_iter_mut() {
app.logic(ctx);
}
}
fn ui(&mut self, ui: &mut egui::Ui, frame: &mut eframe::Frame) {
#[cfg(target_arch = "wasm32")]
if let Some(anchor) = frame