mirror of
https://github.com/emilk/egui.git
synced 2026-08-30 05:10:03 -04:00
Add ViewportInfo::occluded and visible (#7948)
* Part of https://github.com/emilk/egui/issues/5112 * Part of https://github.com/emilk/egui/issues/5113 * Part of https://github.com/emilk/egui/issues/5136 Once we support calling `App::logic` when an app is occluded or minimized, it is useful to know that it is, in fact, occluded or minimized. --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -31,11 +31,18 @@ impl WebInput {
|
||||
time: Some(super::now_sec()),
|
||||
..self.raw.take()
|
||||
};
|
||||
raw_input
|
||||
let viewport = raw_input
|
||||
.viewports
|
||||
.entry(egui::ViewportId::ROOT)
|
||||
.or_default()
|
||||
.native_pixels_per_point = Some(super::native_pixels_per_point());
|
||||
.or_default();
|
||||
viewport.native_pixels_per_point = Some(super::native_pixels_per_point());
|
||||
|
||||
// A hidden browser tab is effectively occluded.
|
||||
let hidden = web_sys::window()
|
||||
.and_then(|w| w.document())
|
||||
.is_some_and(|doc| doc.hidden());
|
||||
viewport.occluded = Some(hidden);
|
||||
|
||||
raw_input
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user