Skip to content

Commit

Permalink
Fire visibilitychange event appropriately
Browse files Browse the repository at this point in the history
  • Loading branch information
Manishearth committed Oct 11, 2019
1 parent 75c7631 commit d90317c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions components/atoms/static_atoms.txt
Expand Up @@ -123,6 +123,7 @@ transitionend
unhandledrejection
unload
url
visibilitychange
volumechange
waiting
webglcontextcreationerror
Expand Down
18 changes: 17 additions & 1 deletion components/script/dom/xrsession.rs
Expand Up @@ -49,7 +49,7 @@ use profile_traits::ipc;
use std::cell::Cell;
use std::mem;
use std::rc::Rc;
use webxr_api::{self, EnvironmentBlendMode, Event as XREvent, Frame, SelectEvent, Session};
use webxr_api::{self, EnvironmentBlendMode, Event as XREvent, Frame, SelectEvent, Session, Visibility};

#[dom_struct]
pub struct XRSession {
Expand Down Expand Up @@ -214,6 +214,22 @@ impl XRSession {
frame.set_active(false);
}
},
XREvent::VisibilityChange(v) => {
let v = match v {
Visibility::Visible => XRVisibilityState::Visible,
Visibility::VisibleBlurred => XRVisibilityState::Visible_blurred,
Visibility::Hidden => XRVisibilityState::Hidden,
};
self.visibility_state.set(v);
let event = XRSessionEvent::new(
&self.global(),
atom!("visibilitychange"),
false,
false,
self,
);
event.upcast::<Event>().fire(self.upcast());
},
_ => (), // XXXManishearth TBD
}
}
Expand Down

0 comments on commit d90317c

Please sign in to comment.