Increase accuracy of various Web APIs (#2946)

This commit is contained in:
daxpedda 2023-07-10 23:55:43 +02:00 committed by GitHub
parent db8de03142
commit c4d70d75c1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 73 additions and 38 deletions

View file

@ -400,12 +400,17 @@ impl<T: 'static> Shared<T> {
if !runner.0.suspended.get() {
for (id, canvas) in &*runner.0.all_canvases.borrow() {
if let Some(canvas) = canvas.upgrade() {
if backend::is_intersecting(runner.window(), canvas.borrow().raw()) {
let is_visible = backend::is_visible(runner.window());
// only fire if:
// - not visible and intersects
// - not visible and we don't know if it intersects yet
// - visible and intersects
if let (false, Some(true) | None) | (true, Some(true)) =
(is_visible, canvas.borrow().is_intersecting)
{
runner.send_event(Event::WindowEvent {
window_id: *id,
event: WindowEvent::Occluded(!backend::is_visible(
runner.window(),
)),
event: WindowEvent::Occluded(!is_visible),
});
}
}