Skip to content
Permalink
Browse files

Add support for squeeze events

  • Loading branch information
Manishearth committed Nov 22, 2019
1 parent 10a63cc commit 87f729731a4f97f4605f1ee186fa8701147f6af3

Some generated files are not rendered by default. Learn more.

@@ -107,6 +107,9 @@ selectend
selectstart
serif
signalingstatechange
squeeze
squeezeend
squeezestart
srclang
statechange
stroke
@@ -39,8 +39,11 @@ interface XRSession : EventTarget {
// // Events
attribute EventHandler onend;
attribute EventHandler onselect;
attribute EventHandler onsqueeze;
// attribute EventHandler oninputsourceschange;
attribute EventHandler onselectstart;
attribute EventHandler onselectend;
attribute EventHandler onsqueezestart;
attribute EventHandler onsqueezeend;
attribute EventHandler onvisibilitychange;
};
@@ -47,7 +47,8 @@ use std::cell::Cell;
use std::mem;
use std::rc::Rc;
use webxr_api::{
self, EnvironmentBlendMode, Event as XREvent, Frame, SelectEvent, Session, Visibility,
self, EnvironmentBlendMode, Event as XREvent, Frame, SelectEvent, SelectKind, Session,
Visibility,
};

#[dom_struct]
@@ -218,27 +219,33 @@ impl XRSession {
let event = XRSessionEvent::new(&self.global(), atom!("end"), false, false, self);
event.upcast::<Event>().fire(self.upcast());
},
XREvent::Select(input, kind, frame) => {
XREvent::Select(input, kind, ty, frame) => {
use servo_atoms::Atom;
const START_ATOMS: [Atom; 2] = [atom!("selectstart"), atom!("squeezestart")];
const EVENT_ATOMS: [Atom; 2] = [atom!("select"), atom!("squeeze")];
const END_ATOMS: [Atom; 2] = [atom!("selectend"), atom!("squeezeend")];

// https://immersive-web.github.io/webxr/#primary-action
let source = self.input_sources.find(input);
let atom_index = if kind == SelectKind::Squeeze { 1 } else { 0 };
if let Some(source) = source {
let frame = XRFrame::new(&self.global(), self, frame);
frame.set_active(true);
if kind == SelectEvent::Start {
if ty == SelectEvent::Start {
let event = XRInputSourceEvent::new(
&self.global(),
atom!("selectstart"),
START_ATOMS[atom_index].clone(),
false,
false,
&frame,
&source,
);
event.upcast::<Event>().fire(self.upcast());
} else {
if kind == SelectEvent::Select {
if ty == SelectEvent::Select {
let event = XRInputSourceEvent::new(
&self.global(),
atom!("select"),
EVENT_ATOMS[atom_index].clone(),
false,
false,
&frame,
@@ -248,7 +255,7 @@ impl XRSession {
}
let event = XRInputSourceEvent::new(
&self.global(),
atom!("selectend"),
END_ATOMS[atom_index].clone(),
false,
false,
&frame,
@@ -353,6 +360,15 @@ impl XRSessionMethods for XRSession {
/// https://immersive-web.github.io/webxr/#eventdef-xrsession-selectend
event_handler!(selectend, GetOnselectend, SetOnselectend);

/// https://immersive-web.github.io/webxr/#eventdef-xrsession-squeeze
event_handler!(squeeze, GetOnsqueeze, SetOnsqueeze);

/// https://immersive-web.github.io/webxr/#eventdef-xrsession-squeezestart
event_handler!(squeezestart, GetOnsqueezestart, SetOnsqueezestart);

/// https://immersive-web.github.io/webxr/#eventdef-xrsession-squeezeend
event_handler!(squeezeend, GetOnsqueezeend, SetOnsqueezeend);

/// https://immersive-web.github.io/webxr/#eventdef-xrsession-visibilitychange
event_handler!(
visibilitychange,
@@ -169,13 +169,3 @@

[WebGLRenderingContext includes WebGLRenderingContextBase: member names are unique]
expected: FAIL

[XRSession interface: attribute onsqueeze]
expected: FAIL

[XRSession interface: attribute onsqueezestart]
expected: FAIL

[XRSession interface: attribute onsqueezeend]
expected: FAIL

0 comments on commit 87f7297

Please sign in to comment.
You can’t perform that action at this time.