Add support for squeeze events

This commit is contained in:
Manish Goregaokar 2019-11-21 16:31:08 -08:00
parent 10a63cc9d4
commit 87f729731a
5 changed files with 31 additions and 19 deletions

4
Cargo.lock generated
View file

@ -6007,7 +6007,7 @@ dependencies = [
[[package]]
name = "webxr"
version = "0.0.1"
source = "git+https://github.com/servo/webxr#27c83fde49d820bc3ffd0396d9aea01a3b5c5729"
source = "git+https://github.com/servo/webxr#e44552df536a6f424d58ccd068aa0301fee5fa1e"
dependencies = [
"bindgen",
"euclid",
@ -6027,7 +6027,7 @@ dependencies = [
[[package]]
name = "webxr-api"
version = "0.0.1"
source = "git+https://github.com/servo/webxr#27c83fde49d820bc3ffd0396d9aea01a3b5c5729"
source = "git+https://github.com/servo/webxr#e44552df536a6f424d58ccd068aa0301fee5fa1e"
dependencies = [
"euclid",
"ipc-channel",

View file

@ -107,6 +107,9 @@ selectend
selectstart
serif
signalingstatechange
squeeze
squeezeend
squeezestart
srclang
statechange
stroke

View file

@ -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;
};

View file

@ -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,16 +219,22 @@ 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,
@ -235,10 +242,10 @@ impl XRSession {
);
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,

View file

@ -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